VBA to check for new sheets and add cell info from them

Jessica553

New Member
Joined
Nov 21, 2021
Messages
24
Office Version
  1. 2010
Platform
  1. Windows
Hello, I found this code online and have used it to create a list of new worksheets and pick up the information from specific cells - in this case B13.
I want to amend it so that I can also pick up A2 and pull the result into Sheet1 (Asset List) next to the result from B13. But I don't know where to begin.

This is what I want the result to be in the sheet 'Asset List'. I have the 'Asset Info Sheet 1' in A2 working and the $800 in B2 comes through from it's sheet (B13 on its sheet) but I want the 305562 to come through as well also from B13. Hope that makes sense.

Thank you in advance, I am very new and learn as I go so not sure what all the bits mean.

Capitalisation ValueAsset Number
Asset Info Sheet 1
$800.00​
305562

CODE:


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Not Intersect(Target, Sh.Range("B13")) Is Nothing Then
Dim ws As Worksheet
Set ws = Sheets("Asset List")
Dim iRow As Integer
On Error GoTo Yikes:
TryAgain:
iRow = Application.WorksheetFunction.Match(Sh.Name, ws.Range("A1:A50"), 0)
ws.Cells(iRow, 2) = Target.Value
Exit Sub

Yikes:

Dim rowcount As Integer
rowcount = ws.Cells(Rows.Count, 1).End(xlUp).Row
Dim r As Range
Set r = ws.Cells(rowcount + 1, 1)
r = Sh.Name
GoTo TryAgain:
End If
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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