Forming a variable from variables

Rahadian

Board Regular
Joined
May 5, 2005
Messages
81
Hello,

I tried to search this topic here but could not find it, so I wonder if you could help me with my scripts.

Basically I have a lot of data in form of XYYZZ where X is a characters and YY and ZZ are numeric (e.g A1126, A1926 etc). For each combination of X and Y I want to get the maximum number of YY so I came up with the following scripts:

Sub get_max()
Dim X, XRow, Yr, Pk, Seq
Dim A11, A16, A21, A26, A31, A36, A41, A50
Dim I11, I16, I21, I26, I31, I36, I41, I50
Dim P11, P16, P21, P26, P31, P36, P41, P50

Sheets("Register").Activate

XRow = [g1048576].End(xlUp).Row

For X = 3 To XRow
Yr = Right(Cells(X, 7), 2)
Seq = Mid(Cells(X, 7), 2, 2)
Pk = Left(Cells(X, 7), 1)
Pk & Yr = Seq
Next

End sub

The script fails when evaluates the variable Pk & Yr = Seq, is there a way to form a variable from variables ?

Thanks in advance for your help.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
The short answer is No but perhaps there's another approach you could take.

What do you actually have in the cells Yr, Seq and Pk are being populated from?

Also, are these variables meant to be cell references?
Code:
Dim A11, A16, A21, A26, A31, A36, A41, A50
Dim I11, I16, I21, I26, I31, I36, I41, I50
Dim P11, P16, P21, P26, P31, P36, P41, P50
 
Upvote 0

Forum statistics

Threads
1,217,364
Messages
6,136,115
Members
449,993
Latest member
Sphere2215

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