Dear all,
I'm in the market for a string of VBA code that will either delete unnecessary rows or add additional rows depending on a changing variable selected at the beginning of a process. Some more details:
The changing variable I mentioned is a list of countries. When you select the country it generates a list of all sites within that country in Sheet 1. Sheet 2 contains a formula which replicates each site 10 times underneath one another.
Obviously the different countries will have a varying number of sites operating within them, and as a result the number of rows in Sheet 2 will vary depending on the country you select. I then have to manually delete the unnecessary rows or add additional rows in Sheet 2, depending on the country selected in Sheet 1 in order for the formulas to function properly.
To help this process I have a formula in Sheet 1 E16 which calculates what the very bottom line of my data table in Sheet 2 needs to be, and converts it into a cell reference. For example: I select the UK, the formula calculates that the bottom row of the data table should be row 100, converted to cell reference A100. I then use "Go To" (Ctrl + G) to quickly go to that bottom row in Sheet 2. I then delete all unnecessary rows beneath it or fill down (Ctrl + D) so that my data table range is from A12:X100.
I would like a macro to do this automatically. What is needs to is:
1) In Sheet 2, highlight A12:X12 (top row of my data table)
2) Fill down (Ctrl + D) all the way down to A5500:X5500
3) Go to the cell reference calculated in Sheet 1 E16 (A100 for example) and delete all lines below it (A101 and below, for example).
Any assistance will be greatly appreciated.
Many thanks
I'm in the market for a string of VBA code that will either delete unnecessary rows or add additional rows depending on a changing variable selected at the beginning of a process. Some more details:
The changing variable I mentioned is a list of countries. When you select the country it generates a list of all sites within that country in Sheet 1. Sheet 2 contains a formula which replicates each site 10 times underneath one another.
Obviously the different countries will have a varying number of sites operating within them, and as a result the number of rows in Sheet 2 will vary depending on the country you select. I then have to manually delete the unnecessary rows or add additional rows in Sheet 2, depending on the country selected in Sheet 1 in order for the formulas to function properly.
To help this process I have a formula in Sheet 1 E16 which calculates what the very bottom line of my data table in Sheet 2 needs to be, and converts it into a cell reference. For example: I select the UK, the formula calculates that the bottom row of the data table should be row 100, converted to cell reference A100. I then use "Go To" (Ctrl + G) to quickly go to that bottom row in Sheet 2. I then delete all unnecessary rows beneath it or fill down (Ctrl + D) so that my data table range is from A12:X100.
I would like a macro to do this automatically. What is needs to is:
1) In Sheet 2, highlight A12:X12 (top row of my data table)
2) Fill down (Ctrl + D) all the way down to A5500:X5500
3) Go to the cell reference calculated in Sheet 1 E16 (A100 for example) and delete all lines below it (A101 and below, for example).
Any assistance will be greatly appreciated.
Many thanks