+ Reply to Thread
Results 1 to 8 of 8

Vba code to loop A:A and change value in current row

Hybrid View

Grahamfeeley Vba code to loop A:A and... 08-17-2018, 01:32 AM
kersplash Re: Vba code to loop A:A and... 08-17-2018, 01:34 AM
Grahamfeeley Re: Vba code to loop A:A and... 08-17-2018, 01:50 AM
kersplash Re: Vba code to loop A:A and... 08-17-2018, 01:53 AM
Grahamfeeley Re: Vba code to loop A:A and... 08-17-2018, 02:08 AM
Norie Re: Vba code to loop A:A and... 08-17-2018, 01:45 AM
jindon Re: Vba code to loop A:A and... 08-17-2018, 02:22 AM
Grahamfeeley Re: Vba code to loop A:A and... 08-17-2018, 02:27 AM
  1. #1
    Forum Contributor
    Join Date
    03-30-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Excel 2013
    Posts
    274

    Vba code to loop A:A and change value in current row

    Hi I am trying to make a macro to loop through Column A , which is a date field dd/mm/yyyy
    when date changes put value in corresponding row to 100
    column to change is L

    any help will be appreciated
    Graham'

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Vba code to loop A:A and change value in current row

    Attach a sample workbook demonstrating what you have described and mock-up your results.

    Go Advanced -> Manage Attachments -> Upload

  3. #3
    Forum Contributor
    Join Date
    03-30-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Excel 2013
    Posts
    274

    Re: Vba code to loop A:A and change value in current row

    here is a test sample
    thank you in advance
    Graham
    Attached Files Attached Files

  4. #4
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Vba code to loop A:A and change value in current row

    Quote Originally Posted by Grahamfeeley View Post
    here is a test sample
    thank you in advance
    Graham
    What do you mean by the value needs to change when the date changes?

    What does it need to change to? Mock-up the expected values.

    EDIT - Unless Norie's solution works for you.

  5. #5
    Forum Contributor
    Join Date
    03-30-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Excel 2013
    Posts
    274

    Re: Vba code to loop A:A and change value in current row

    Norie this code didnt work
    (1) it said variable not declared so i put in dim arrdata as range
    then it said something regarding Array
    sorry
    Graham

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Vba code to loop A:A and change value in current row

    Try this.
    Dim arrData()
    Dim I As Long
    
        arrData = Range("A2", Range("A" & Rows.Count).End(xlUp))
        
        For I = LBound(arrData) To UBound(arrData) - 1
            If arrData(I, 1) <> arrData(I + 1, 1) Then
                Range("L" & I + 2).Value = 100
            End If
        Next I
    Last edited by Norie; 08-17-2018 at 01:56 AM.
    If posting code please use code tags, see here.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Vba code to loop A:A and change value in current row

    Sub test()
        Dim x As String
        With Range("a2", Range("a" & Rows.Count).End(xlUp))
            x = .Columns(12).Address
            .Columns(12) = Evaluate("if(" & .Address & "<>" & .Offset(-1).Address & ",100,if(" & x & "<>""""," & x & ",""""))")
        End With
    End Sub

  8. #8
    Forum Contributor
    Join Date
    03-30-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Excel 2013
    Posts
    274

    Re: Vba code to loop A:A and change value in current row

    Thanks Jindon works perfectly and it is fast as well
    Much Appreciated
    Regards
    Graham

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Modify Current Code To Loop Thru URLs and Provide Error Statement
    By superdesi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-09-2016, 05:01 PM
  2. Change current code to enable email info to be copied into new excel doc
    By vman5781 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-06-2016, 04:25 PM
  3. Add loop to current code
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-19-2013, 05:07 PM
  4. Replies: 4
    Last Post: 09-09-2013, 05:06 AM
  5. [SOLVED] How can I modify my current code to not change once populated
    By Dena in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-05-2013, 01:52 PM
  6. Change code to look for current worksheet?
    By dalewms2 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-08-2011, 03:35 PM
  7. Adding loop to current code?
    By RJ138 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-07-2010, 06:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1