Results 1 to 5 of 5

VBA Looping with Ifs

Threaded View

  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!

                Dim Z As Range, rng
                
                Set rng = Range("AW6:AW" & Range("AW65536").End(xlUp).Row)
                
                For Each Z In rng
                
                If InStr(Z, "1") Then
                        
                        If InStr(Z.Offset(0, -47), "40") Then
                        Z.Offset(0, -47).Select
                        ActiveCell.FormulaR1C1 = "11"
                        End If
                        
                        If InStr(Z.Offset(0, -47), "50") Then
                        Z.Offset(0, -47).Select
                        ActiveCell.FormulaR1C1 = "01"
                        End If
                        
                    Z.Offset(0, -46).Select
                    ActiveCell.FormulaR1C1 = ""Cook""
                              
    
                End If
                Next Z
    Last edited by harrison298; 09-20-2012 at 01:00 PM.

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