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
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

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
 

Watch MrExcel Video

Forum statistics

Threads
1,109,445
Messages
5,528,801
Members
409,835
Latest member
Mafu1267

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top