Extracting data from a table and entering it into specific cells on a sheet

Tony_Y

New Member
Joined
May 29, 2020
Messages
35
Office Version
  1. 365
Platform
  1. Windows
Good evening,

I have been using a code for some time now which extracted data from a table and entered the information into specific cells on another worksheet within the same workbook. Now for some reason it is giving me a runtime error 91 Object variable or with block variable not set. When I go to debug it is highlighting the row "f = fCell.Row"
Any help or a point in the right direction will be greatly appreciated.

Tony

My code is:


Rich (BB code):
Sub DataToAmend()

Dim ws As Worksheet
Dim x As Long
Dim fCell As Range
Set ws = ThisWorkbook.Sheets("DATA TABLE")

Application.ScreenUpdating = False


Set fCell = Sheets("DATA TABLE").Range("A:A").Find(Range("Amendsite_name").Value, , xlValues, xlWhole)

x = fCell.Row

With ws

Sheets("DATA AMEND").Range("Amensite_add1").Value = Sheets("DATA TABLE").Cells(x, 5).Value
Sheets("DATA AMEND").Range("Amendsite_add2").Value = Sheets("DATA TABLE").Cells(x, 6).Value
Sheets("DATA AMEND").Range("Amendsite_post").Value = Sheets("DATA TABLE").Cells(x, 7).Value
Sheets("DATA AMEND").Range("Amendsite_cont").Value = Sheets("DATA TABLE").Cells(x, 8).Value
Sheets("DATA AMEND").Range("Amendclient_name").Value = Sheets("DATA TABLE").Cells(x, 9).Value
Sheets("DATA AMEND").Range("Amendclient_add1").Value = Sheets("DATA TABLE").Cells(x, 10).Value
Sheets("DATA AMEND").Range("Amendclient_add2").Value = Sheets("DATA TABLE").Cells(x, 11).Value
Sheets("DATA AMEND").Range("Amendclient_post").Value = Sheets("DATA TABLE").Cells(x, 12).Value
Sheets("DATA AMEND").Range("Amendclient_cont").Value = Sheets("DATA TABLE").Cells(x, 13).Value
Sheets("DATA AMEND").Range("Amendmeter_des").Value = Sheets("DATA TABLE").Cells(x, 14).Value
Sheets("DATA AMEND").Range("Amendpipe_mat").Value = Sheets("DATA TABLE").Cells(x, 18).Value
Sheets("DATA AMEND").Range("Amendmip").Value = Sheets("DATA TABLE").Cells(x, 19).Value
Sheets("DATA AMEND").Range("Amendmop").Value = Sheets("DATA TABLE").Cells(x, 20).Value
Sheets("DATA AMEND").Range("Amendop").Value = Sheets("DATA TABLE").Cells(x, 21).Value
Sheets("DATA AMEND").Range("Amendinc_10").Value = Sheets("DATA TABLE").Cells(x, 23).Value
Sheets("DATA AMEND").Range("Amendtest_gas").Value = Sheets("DATA TABLE").Cells(x, 24).Value
Sheets("DATA AMEND").Range("Amendop_gas").Value = Sheets("DATA TABLE").Cells(x, 25).Value
Sheets("DATA AMEND").Range("Amendguage").Value = Sheets("DATA TABLE").Cells(x, 26).Value
Sheets("DATA AMEND").Range("Amendinst_type").Value = Sheets("DATA TABLE").Cells(x, 27).Value
Sheets("DATA AMEND").Range("Amendarea_type").Value = Sheets("DATA TABLE").Cells(x, 28).Value
Sheets("DATA AMEND").Range("Amendsmall").Value = Sheets("DATA TABLE").Cells(x, 29).Value
Sheets("DATA AMEND").Range("Amendpurge").Value = Sheets("DATA TABLE").Cells(x, 30).Value
Sheets("DATA AMEND").Range("AmendEng_note").Value = Sheets("DATA TABLE").Cells(x, 32).Value

Sheets("DATA AMEND").Visible = xlSheetVisible
Sheets("INPUT GUIDE").Visible = xlSheetHidden
Sheet21.Activate
End With

End Sub
 
Last edited by a moderator:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
That means the search value cannot be found.
 
Upvote 0
Ah I see. I don't know what had changed but it's sorted. Many thanks for the prompt reply Fluff. Greatly appreciated once more.

Tony
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,272
Members
449,219
Latest member
daynle

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