VBA-Macro

sitelbanat

Board Regular
Joined
Oct 17, 2005
Messages
152
I need help writing a macro that would

if cell AJ116 = any of the columns in row 2 then copy the data in column AG117-141 and paste in the cells that match the currency in column B.

the data in AF117-114 has the currencies AG117-114 has the amounts

cell AJ116 = one of the dates from row 2

and column B has different currencies

B2 = usd
B3 = aud
B4 = nok

and row 2 has a different date in every column

help


i want the macro to paste the amounts into the right date with the right currencies
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

agihcam

Well-known Member
Joined
Jan 16, 2006
Messages
1,624
not sure if this you are after but try;
Code:
Sub test()
Dim i As Long
'find the column# where the date is
With Rows(2)
    Set c = .Find(Range("aj116").Value, , , xlWhole)
        If Not c Is Nothing Then
            rfnd = c.Column
        End If
End With

'find the match currencies of all the records from aj117 to last row
'and put the values in desired date column
For i = 117 To Range("af" & Rows.Count).End(xlUp).Row
    With Columns("b")
        Set fc = .Find(Cells(i, "af").Value, , , xlWhole)
            If Not fc Is Nothing Then
                On Error GoTo err:
                    Cells(fc.Row, rfnd).Value = Cells(i, "ag").Value
            End If
    End With
Next
'if no date found from row 2
err:
MsgBox "Date: " & Range("aj116").Value & " " & " could not be found fron row#2", vbInformation + vbOKOnly, "No Record Found!"
End Sub
 

Forum statistics

Threads
1,141,139
Messages
5,704,514
Members
421,353
Latest member
jekoxien15

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top