hi!
I need a better way of doing this : I have this macro that I wrote. it does a vlookup from 2 sheets "RMUI" and "Convert". it takes the results and divides it with the number in the RMUI sheets.
instead of doing this for each column below ( Ai, Aj.......to FJ), is it possible to combine all the columns? just a lot of repetition
here is the sample
Sub RMUItoGrams()
On Error Resume Next
Dim RM As Worksheet
Dim conv As Worksheet
Set RM = Sheets("RMUI")
Set conv = Sheets("Convert")
Set myrange = conv.Range("A:B")
lastrow = RM.Range("D" & Rows.Count).End(xlUp).Row
For i = 5 To lastrow
x = Application.WorksheetFunction.VLookup(RM.Range("D" & i), myrange, 2, 0)
' this is where I need to find a solution to reduce this repetition
RM.Range("Ai" & i) = RM.Range("Ai" & i) / x
RM.Range("Aj" & i) = RM.Range("Aj" & i) / x
RM.Range("Ak" & i) = RM.Range("Ak" & i) / x
RM.Range("Al" & i) = RM.Range("Al" & i) / x
RM.Range("Am" & i) = RM.Range("Am" & i) / x
RM.Range("An" & i) = RM.Range("An" & i) / x
RM.Range("Ao" & i) = RM.Range("Ao" & i) / x
Next i
End Sub
Bookmarks