![]() |
Backwards compatibile macro
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 |
All times are GMT +1. The time now is 01:54 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com