VBA array exercise

dkohli

New Member
Joined
Feb 4, 2018
Messages
8
Use the data in the ‘Data’ worksheet of the workbook “VBA Training Exercise 2” (attached image) and segregate it on the basis of ‘Type’. Please follow the below points:

  1. Find unique ‘Types’ of Roller coasters in the given data.
  2. Add new worksheets in the same workbook and name them on the type of Roller Coaster. (So based on the current data, you will have to create three sheets by the name of unique ‘Type’ - Alloys, Wood and Steel).
  3. Each sheet should contain the Roller Coaster and Amusement Park name according to the type of roller coaster. For e.g. the ‘Alloys’ sheet should contain Roller Coaster – Air and Amusement Park – Alton Towers and so on, as shown in the below table -

Data is given below

Roller CoasterAmusement ParkType
Air Alton TowersAlloys
Boomerang Pleasure IslandSteel
Cobra Paultons Park Wood
ColossusThorpe ParkWood
CorkscrewAlton TowersAlloys
CorkscrewFlamingo Steel
Crazy MouseSouth PierAlloys
Crazy MouseBrighton PierWood
EnigmaPleasurewoodSteel
ExpressScotland's Theme park Alloys
Fantasy MouseFantasy IslandAlloys
G ForceManor Park Wood
Grand National Pleasure BeachSteel
InfusionPleasure BeachWood
IRN-BRU RevolutionPleasure BeachWood

<tbody>
</tbody><colgroup><col><col><col></colgroup>

Roller Coaster
Amusement Park
Air
Alton Towers
Corkscrew
Alton Towers
Crazy Mouse
South Pier
Express
Scotland's Theme park
Fantasy Mouse
Fantasy Island

<tbody>
</tbody>

Additional Information 1 – The code should be dynamic in nature so as to handle modified/additional/lesser data than the one currently fed in the attached file. That is, the code should still work in case further ‘Type’ of roller coasters is added or the current data is reduced to 1 or 2 ‘Type’. (The data entries will always start from row 2, but can have any number of entries)

Additional Information 2 – Create your code in such manner that the user has to only input/change the data manually and then run the code without any further manual intervention. Assume that there will be no blank entries in the data.

Notes for good Coding practice – Declare all the used variables. Add ‘Option Explicit’ at the top of the module to help find any undeclared variable. Give meaningful names to variables declared. Additionally, as discussed, Please use the indentation (‘Tab’ key on the keyboard) for the statements within ‘IF_Else’ and Loops to help with the review. Add your comments at the start of each block of code to help with the review.

Hint1 – Find the last row used to find the number of total entries. This will help you avoiding blank runs in the loops and save up you run time.
Hint2 – You can store the unique ‘Type’ in a dynamic array which can be used going forward in the code.
Hint3 – Delete all the sheets except for Data sheets when rerunning the code to avoid errors.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Re: Help needed with VBA array exercise urgent

hello. What specific help is wanted?
 
Upvote 0
Re: Help needed with VBA array exercise urgent

This is the data
Roller CoasterAmusement ParkType
Air Alton TowersAlloys
Boomerang Pleasure IslandSteel
Cobra Paultons Park Wood
ColossusThorpe ParkWood
CorkscrewAlton TowersAlloys
CorkscrewFlamingo Steel
Crazy MouseSouth PierAlloys
Crazy MouseBrighton PierWood
EnigmaPleasurewoodSteel
ExpressScotland's Theme park Alloys
Fantasy MouseFantasy IslandAlloys
G ForceManor Park Wood
Grand National Pleasure BeachSteel
InfusionPleasure BeachWood
IRN-BRU RevolutionPleasure BeachWood

<tbody>
</tbody><colgroup><col><col><col></colgroup>
 
Upvote 0
Re: Help needed with VBA array exercise urgent

and this is the question:

  1. Find unique ‘Types’ of Roller coasters in the given data.
  2. Add new worksheets in the same workbook and name them on the type of Roller Coaster. (So based on the current data, you will have to create three sheets by the name of unique ‘Type’ - Alloys, Wood and Steel).
  3. Each sheet should contain the Roller Coaster and Amusement Park name according to the type of roller coaster. For e.g. the ‘Alloys’ sheet should contain Roller Coaster – Air and Amusement Park – Alton Towers and so on, as shown in the below table -

Roller Coaster
Amusement Park
Air
Alton Towers
Corkscrew
Alton Towers
Crazy Mouse
South Pier
Express
Scotland's Theme park
Fantasy Mouse
Fantasy Island

<tbody>
</tbody>
 
Upvote 0
Lets take this step by step
Please let me know the code to find out unique type in each column
 
Upvote 0
or maybe collections
or use advanced filter
or a query using SELECT DISTINCT
for sure there will be many other ways

please post the code you have with description of the bit for which you want help
 
Upvote 0

Forum statistics

Threads
1,215,336
Messages
6,124,338
Members
449,155
Latest member
ravioli44

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