VBA Referencing a Worksheets' "name" dynamically from a list

Boomer1962

New Member
Joined
Jul 4, 2023
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I have data in a source worksheet in rows. The number of rows and columns will vary so I must refer to them dynamically. The first column contains store numbers which are the Tab Names in my destinations workbook.
I only need to properly identify the destination Tab Name from the list in the source worksheet in order to copy the data in the subsequent columns.

I have this so far but I am getting errors.
VBA Code:
Dim Store As String
Dim s As Long
Dim wsDest As Worksheet
Dim lrDest As Long
Dim Qty As Long
Dim sheetname As String





For s = 7 To lr
   Application.Calculation = xlCalculationManual
    
    Set wsDest = Workbooks("Copie de Facturation Juillet 2023 2.xlsx").Sheets(??????)
    
        For c = storecol + 1 To lc
            lrDest = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
               Qty = Cells(s, c).Value
               wsDest.Cells(lrDest, 4).Value = Qty
               Next
           Next

My problem is how do I identify the Sheets(????) so that the destination Worksheet changes with each iteration of my loop?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Please note that I need to find the proper destination worksheet as they are not necessarily sequential. Sometimes I may skip some stores.
 
Upvote 0

Forum statistics

Threads
1,215,274
Messages
6,123,998
Members
449,137
Latest member
abdahsankhan

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