Beginner Code check : checking data before creating 2d array

PJ0302917

New Member
Joined
Aug 28, 2017
Messages
10
Hi, thanks in advance for the help, i used to be a programmer but have never used VBA and was hoping to bounce a few idea's.


I have a large worksheet and i'm trying to use VBA to automate some comparing of message data i have in Excel. I've been carrying out the checks manually up unit now and its pretty boring.


The first 10 rows of the worksheet is basically message header information for the 10 types of messages (data) i'm analyzing (this is variable, sometimes i have 20 messages).
The following 5,000 lines is the actual data. I'm fortunate that the first column for each row can be used to see if its a header or data. If its a timestamp, its data.


I've decided to create a Message 2D Array and a Data 2D Array to manipulate the data. I'm working is small steps and first task was to build the two arrays. Here is the code i'm using, i should mention the messages have different numbers of attributes. Below is the code i'm using to find the max number of columns used by all the header rows. I then plan to create a 2D Array called messages. Does the code below look ok or is there an easier way?


'Get number of columns needed for Messages[]'
Do Until ActiveCell.Value <> "Header"
localMaxMessageAttributes = Worksheets("Data").Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Column
If localMaxMessageAttributes > maxMessageAttributes Then
maxMessageAttributes = localMaxMessageAttributes
End If

ActiveCell.Offset(1, 0).Select
Loop
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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