+ Reply to Thread
Results 1 to 5 of 5

VBA Looping with Ifs

  1. #1
    Registered User
    Join Date
    09-10-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    17

    VBA Looping with Ifs

    I am pretty new to VBA, however i have been tryinig to crack looping macros, and had a bit of success with it so far. However i cant seem to get this one. What i want the macro to do is go down column AW from row 6 down. Every time it encouters a 1, i want it to go to column b in the row the 1 is on. If that cell contains a 40, i need it to replace it with an "11". if the cell contains a 50, i need it to replace it with a "01". Then, on the same row, in column C replace what is there with a "Cook". Once this has ended, continue down Column AW till it reaches another "1"

    Here is my attempt so far, any help with this would be amazing!

    Please Login or Register  to view this content.
    Last edited by harrison298; 09-20-2012 at 01:00 PM.

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: VBA Help!

    Looks Like maybe you missing the 1 at the begining of your Instr(1,Z,"1")

    But heres another was without the range. Easier to manage I think

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    09-10-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: VBA Help!

    Hi Mark,

    Thanks for the reply!

    It doesnt seem to be working though. It seems to run down the cells in AW fine, however it doesnt seem to be putting the values in the cell

    Is it because there is already a value in the cell, and the macro needs to replace the cell contents?

    Thanks

    Alex

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: VBA Looping with Ifs

    This should do it for you. You had it looking in column Z for a 1

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-10-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: VBA Looping with Ifs

    Perfect! Thankyou Mike!! Really appreciate your help!

    Alex

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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