Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
Hi,
I'm using Excel 2010. I have a macro saved in the personal workbook but it doesn't work on workbooks in compatibility mode. If I save the macro directly into the older version workbook, the macro works fine. Would anybody know how to make my code work regardless of which version the workbook is? Here is the code I have: Sub ForEachCellInRange() Dim iCell As Range Dim rowNo As Integer For Each iCell In Sheet1.Range("A1:A20") rowNo = iCell.Row If Sheet1.Cells(rowNo, 1) Like "ABC123" And Sheet1.Cells(rowNo, 2) Like "5 gal bucket" And Sheet1.Cells(rowNo, 3) Like "Car" Then Sheet1.Cells(rowNo, 4).Value = "1F" ElseIf Sheet1.Cells(rowNo, 1) Like "ADC321" And Sheet1.Cells(rowNo, 2) Like "25 gal bucket" And Sheet1.Cells(rowNo, 3) Like "Tractor" Then Sheet1.Cells(rowNo, 4).Value = "2F" ElseIf Sheet1.Cells(rowNo, 1) Like "EDK293" And Sheet1.Cells(rowNo, 2) Like "10 gal bucket" And Sheet1.Cells(rowNo, 3) Like "Truck" Then Sheet1.Cells(rowNo, 4).Value = "3F" ElseIf Sheet1.Cells(rowNo, 1) Like "REA322" And Sheet1.Cells(rowNo, 2) Like "15 gal bucket" And Sheet1.Cells(rowNo, 3) Like "Scooter" Then Sheet1.Cells(rowNo, 4).Value = "4F" End If Next iCell End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
The A,B,C,D at the top of my page are backwards | Excel Discussion (Misc queries) | |||
Backwards lookup | Excel Worksheet Functions | |||
backwards sum | Excel Programming | |||
Stepping through For Each...Next backwards? | Excel Programming | |||
Tab backwards | Excel Programming |