Excel VBA to Match Cell in Summary to Workbook Name and Copy information to Summary

Iris14

New Member
Joined
Feb 16, 2014
Messages
11
Hello, I have a REIT summary worksheet which contains different account names starting from Cell A4.

Within the whole workbook, there are also different tabs, each named by the account name and contained information of that account.

I would like to build a macro which find the account name in the REIT summary tab that matches its respective tab and copy cell information from the last cell of column G in that worksheet to the REIT summary tab in column B.

This is what I had so far and it does not work... I guess the reason is because I have put two FOR functions in the macro.

Sub Macro1()


Dim x As Range
Dim wkSht As Worksheet


Set x = Range(Worksheets("REIT Summary").Cells(4, 1), Worksheets("REIT Summary").Cells(Rows.Count, 1).End(xlUp))
For Each Cell In x
For Each wkSht In Sheets

On Error Resume Next


If Sheets("REIT Summary").Cells("x").Value = wkSht.Name Then

wkSht.LastRow = Cells(Rows.Count, 1).End(xlUp).Row
wkSht.Cells(LastRow + 1, 7).Value.Copy
Sheets("REIT Summary").Cells(x, 2).PasteSpecial xlPasteAll

End If


Next
Next


End Sub


[h=1][/h]
I am a totally beginner for writing macro.. any help would be greatly appreciated !!! Thanks !
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,215,473
Messages
6,125,018
Members
449,203
Latest member
tungnmqn90

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