Variable within a variable

austinpcherry

New Member
Joined
Feb 26, 2014
Messages
36
I am setting up a Form in VBA. I have all of my variables and types set properly. The purpose is for units with unique numbers and varying counts.
So item number 100 may be made up of 30 pieces.
I can have multiple unique items per order.
My form gets a total number of items, then asks for each item number, then the count of pieces on each item.
I am using a loop to copy and paste cells for each item onto my printable form. While in my loop I want to call my variables and fill-in the data associated with the variables.
Code:
For j = 1 to (total number of items)
m=11+j *for spacing purposes
Worksheets(reference").range("a12:g12").copy Worksheets(ws.name).range("a1").offset(m,0)
Range(cells(,.5), cells(m,6)).mergecells =true
Next j
What I want to do is to insert a line before the "Next j" that puts the information stored in variables "item1" - "item4" where they exist using the j variable to specify the item#. So itemj, so that it uses the appropriate item# based on which time it copied the reference cells.


How can I do that? Have I coded myself into a corner? Have I set the whole thing up incorrectly?
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
11,938
Office Version
2007
Platform
Windows
You can put examples of what you have in the userform and what you expect from the result in the sheet.
If you could put images with explanations it would be great.
 

Watch MrExcel Video

Forum statistics

Threads
1,100,138
Messages
5,472,741
Members
406,834
Latest member
RahafKh

This Week's Hot Topics

Top