RichFowler
New Member
- Joined
- Jul 13, 2021
- Messages
- 1
- Office Version
- 2013
- Platform
- 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.
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)