Backwards compatibile macro

R

rapio

Hi,
I'm using Excel 2010. I have a macro saved in the personal workbook bu
it doesn't work on workbooks in compatibility mode. If I save the macr
directly into the older version workbook, the macro works fine. Woul
anybody know how to make my code work regardless of which version th
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 Su
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top