macro to put a cell value into the right place in a column

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

thought this would be easy but I'm stuck for some reason.

all it is is I have a sheet called "Invoices"

In Cell G15 I have an Invoice Number
in Cell H10 I have a ref number

now in another sheet called "Records" I have a list of the Ref Numbers (Down column D), so I just want a macro to take the value in cell G15 find the row in "Records" that holds the same ref number as H10 and put the invoice number in that row of column F

So Sheet "Invoices" Cell H10 find match in Sheet "Records" Column D and add to the same row in column F value in "Invoices" cell G15

please help if you can

thanks

Tony
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try:
Code:
Sub CopyCell()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("Records").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Sheets("Records").Range("D1:D" & LastRow).AutoFilter Field:=1, Criteria1:=Sheets("Invoices").Range("H10").Value
    Sheets("Records").Range("F2:F" & LastRow).SpecialCells(xlCellTypeVisible) = Sheets("Invoices").Range("G15").Value
    If Sheets("Records").AutoFilterMode = True Then Sheets("Records").AutoFilterMode = False
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks Mumps, totally different to how I was trying to get it to work, but does the job great :-)
Tony
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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
Back
Top