I have a spreadsheet that contains currency name in col A e.g. USD, AUD etc. Col B contains the amount that needs to be converted into GBP. The calculations will happen in the VBA code below and results stored in col C, D and E</SPAN>
Sub SoSo()</SPAN></SPAN>
Dim Rng As Range</SPAN></SPAN>
Dim rNum As Long</SPAN></SPAN>
Dim LRow As Long</SPAN></SPAN>
LRow = Range("Ccy").Rows.Count</SPAN></SPAN>
For rNum = 1 To LRow + 1</SPAN></SPAN>
Select Case Range("A" & rNum).Value</SPAN></SPAN>
Case "USD"</SPAN></SPAN>
Range("C" & rNum).Value = Range("B" & rNum) / 1.555</SPAN></SPAN>
Range("D" & rNum).Value = Range("B" & rNum) * 1.055</SPAN></SPAN>
Range("E" & rNum).Value = Range("B" & rNum) * 1.015</SPAN></SPAN>
Case "AUD"</SPAN></SPAN>
Range("C" & rNum).Value = Range("B" & rNum) / 2.015</SPAN></SPAN>
Range("D" & rNum).Value = Range("B" & rNum) * 1.055</SPAN></SPAN>
Range("E" & rNum).Value = Range("B" & rNum) * 1.015</SPAN></SPAN>
End Select</SPAN></SPAN>
Next rNum</SPAN></SPAN>
MsgBox "Completed"</SPAN></SPAN>
End Sub</SPAN></SPAN>
The overall spreadsheet will contain about 90,000 rows of data that will need the same procedure to take place. It’s preferable to use named ranges as below instead of col A, B etc.</SPAN>
Questions</SPAN>
Is there a method of using the named ranges for this procedure, currently using the above named ranges is breaking the code?</SPAN>
Is there a method of increasing its efficiency and speed of execution, currently it’s taking several minutes?</SPAN>
Sub SoSo()</SPAN></SPAN>
Dim Rng As Range</SPAN></SPAN>
Dim rNum As Long</SPAN></SPAN>
Dim LRow As Long</SPAN></SPAN>
LRow = Range("Ccy").Rows.Count</SPAN></SPAN>
For rNum = 1 To LRow + 1</SPAN></SPAN>
Select Case Range("A" & rNum).Value</SPAN></SPAN>
Case "USD"</SPAN></SPAN>
Range("C" & rNum).Value = Range("B" & rNum) / 1.555</SPAN></SPAN>
Range("D" & rNum).Value = Range("B" & rNum) * 1.055</SPAN></SPAN>
Range("E" & rNum).Value = Range("B" & rNum) * 1.015</SPAN></SPAN>
Case "AUD"</SPAN></SPAN>
Range("C" & rNum).Value = Range("B" & rNum) / 2.015</SPAN></SPAN>
Range("D" & rNum).Value = Range("B" & rNum) * 1.055</SPAN></SPAN>
Range("E" & rNum).Value = Range("B" & rNum) * 1.015</SPAN></SPAN>
End Select</SPAN></SPAN>
Next rNum</SPAN></SPAN>
MsgBox "Completed"</SPAN></SPAN>
End Sub</SPAN></SPAN>
The overall spreadsheet will contain about 90,000 rows of data that will need the same procedure to take place. It’s preferable to use named ranges as below instead of col A, B etc.</SPAN>
- Col A = Ccy</SPAN>
- Col B = Cost</SPAN></SPAN>
- Col C = Cost_In_GBP</SPAN></SPAN>
- Col D = Commision_1</SPAN></SPAN>
- Col E = Commision_2</SPAN></SPAN>
Questions</SPAN>
Is there a method of using the named ranges for this procedure, currently using the above named ranges is breaking the code?</SPAN>
Is there a method of increasing its efficiency and speed of execution, currently it’s taking several minutes?</SPAN>