copi and paste
Posted: Wed Aug 14, 2024 4:13 pm
hi there
I need your help with vba to transform to convert values from one currency to another currency with division of exchange rate in AD2.
I also need to extract name in column A to column AE like example.how to merge my code into one with simplified vba
thx
I need your help with vba to transform to convert values from one currency to another currency with division of exchange rate in AD2.
I also need to extract name in column A to column AE like example.how to merge my code into one with simplified vba
Code: Select all
Sub Combinetabs()
Sheets.Add
ActiveSheet.Name = "New Sheet"
Set Dsheet = ActiveSheet
For Each ws In Sheets
If ws.Name <> "New Sheet" Then
lr = ws.Cells(Rows.Count, "A").End(xlUp).Row
lr2 = Dsheet.Cells(Rows.Count, "A").End(xlUp).Row
If lr2 = 1 Then lr2 = 0
ws.Rows("1:" & lr).Copy Dsheet.Range("A" & lr2 + 1)
End If
Next ws
End Sub
Sub Transform()
Set sh = ThisWorkbook.Sheets("New Sheet")
lr = sh.Cells(Rows.Count, "B").End(xlUp).Row
usdRate = sh.Range("AD2").Value
For i = 2 To lr
With sh
If .Cells(i, "F").Value = "KHR" Then
.Range("D" & i).Value = .Range("D" & i).Value / usdRate
.Range("E" & i).Value = .Range("E" & i).Value / usdRate
.Range("N" & i).Value = .Range("N" & i).Value / usdRate
.Range("P" & i).Value = .Range("P" & i).Value / usdRate
.Range("Q" & i).Value = .Range("Q" & i).Value / usdRate
.Range("R" & i).Value = .Range("R" & i).Value / usdRate
.Range("T" & i).Value = .Range("T" & i).Value / usdRate
.Range("U" & i).Value = .Range("U" & i).Value / usdRate
.Range("W" & i).Value = .Range("W" & i).Value / usdRate
.Range("X" & i).Value = .Range("X" & i).Value / usdRate
.Range("Y" & i).Value = .Range("Y" & i).Value / usdRate
.Range("Z" & i).Value = .Range("Z" & i).Value / usdRate
End If
End With
Next
End Sub