xenolith01
New Member
- Joined
- Aug 25, 2011
- Messages
- 16
I'm new to VBA and struggling with what I think should be a simple 'For' loop!
I have a set of data that when exported and opened in Excel gives a list of companies and dates of when an order has been placed.
The data contains the company name in column A and date of order in column B.
The orders are grouped by company name starting with the earliest order
The data only puts a company name for the first order date and blanks for any successive orders.
e.g.
Columns
A-----------------B
Company A 02/10/15
--------------08/10/15
--------------12/10/15
--------------18/10/15
Company B 02/10/15
--------------08/10/15
--------------12/10/15
--------------18/10/15
--------------24/10/15
--------------25/10/15
--------------30/10/15
Company C 02/10/15
--------------08/10/15
--------------12/10/15
--------------18/10/15
I need to loop through the data copying the correct company name to the blanks
My current thinking is to first find the row with the last date from column B
Use the row number to create a counter from 1 (or row number where the data starts) to the last row occupied by a date
Perform an IsEmpty check on each cell in column A.
If the cell is not empty copy the value to a variable
loop to the next cell and if empty paste the variable
Continue looping copying and pasting until the last row value
But how!!?
Any ideas to get me started would be appreciated.
Thanks
I have a set of data that when exported and opened in Excel gives a list of companies and dates of when an order has been placed.
The data contains the company name in column A and date of order in column B.
The orders are grouped by company name starting with the earliest order
The data only puts a company name for the first order date and blanks for any successive orders.
e.g.
Columns
A-----------------B
Company A 02/10/15
--------------08/10/15
--------------12/10/15
--------------18/10/15
Company B 02/10/15
--------------08/10/15
--------------12/10/15
--------------18/10/15
--------------24/10/15
--------------25/10/15
--------------30/10/15
Company C 02/10/15
--------------08/10/15
--------------12/10/15
--------------18/10/15
I need to loop through the data copying the correct company name to the blanks
My current thinking is to first find the row with the last date from column B
Use the row number to create a counter from 1 (or row number where the data starts) to the last row occupied by a date
Perform an IsEmpty check on each cell in column A.
If the cell is not empty copy the value to a variable
loop to the next cell and if empty paste the variable
Continue looping copying and pasting until the last row value
But how!!?
Any ideas to get me started would be appreciated.
Thanks