Calling variables

RichFowler

New Member
Joined
Jul 13, 2021
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
Hi,
I've been trying to create a bit of code that looks at a column in an input sheet and then goes to create sheets with data from there.
I've managed to get as far as making the sheet in a clunky way. If there's an 01 in the column next to a value, it makes an invoice and packing list with 01 in the title and fills it out.
This can create up to 4 different sheets. I'm trying to fill in each sheet, and have created a counter for each one (n01, n02, n03, etc.) so that it adds to the bottom of the sheet.
I can make it work with an if, then statement and copy and paste code for the 4 different value, but the code would be quite long. I was wondering if it's possible to create another variable and pass it to the 'cells(' part of it (the commented part was my try, but it's obviously a type mismatch)
Please can anyone help? I'm not even sure my rambling makes much sense.

VBA Code:
invws = "MA" & ws.Cells(x, 15) & " Invoice" 'variable invws is the invoice sheetname (MA + (number) + invoice)
' tmp1 = "n" & ws.Cells(x, 15)


    If ws.Cells(x, 15) = "01" Then
        ' Worksheets(invws).Cells(tmp1 + 24, 1).RowHeight = 45
        Worksheets(invws).Cells(n01 + 24, 1) = ws.Cells(x - 1, 1)
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,141,060
Messages
5,704,041
Members
421,323
Latest member
Exidous

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
Top