Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - VBA Assistance

Status
Not open for further replies.

pbcharlie

Technical User
Jan 16, 2002
55
Hi there. I was wondering if someon could help.

I have a spread sheet that has multiple rows however the row is not prefixed with the date i.e

12/12/06
Fiona Young
Charlie Snedden
13/12/06
Fiona Young
Charlie Snedden

What I need the macro to do is

12/12/06
12/12/06 Fiona Young
12/12/06 Charlie Snedden
13/12/06
13/12/06 Fiona Young
13/12/06 Charlie Snedden

Can somone please point me in the right direction.

I am very new to VBA and Programing

Thanks in advance


Thanks in advance
Charlie
 
There are probably many ways to do this but here's some things to get you started. From your example, it seems like column A will be contiguous for the range of the data. If this is true, and if the data start in row 1, then you find your last row of data, rn:
rn = Cells(1, 1).End(xlDown).Row

Now set a date variable, d1, to the first date, assuming that it is in A1:
d1=cells(1,1)

Now you loop from row 1 to row rn, checking to see if the date changes, putting your new data starting in, say, column 12:
Code:
rb=1
for r=1 to rn
   if isDate(cells(r,1)) then
      d1=cells(r,1)
   else
      cells(rb,12)=d1
      cells(rb,13)=cells(r,1)
      cells(rb,14)=cells(r,2)
      ' and so on
      rb=rb+1
   end if
next

_________________
Bob Rashkin
 
This looks good, I can see the logic behind it. Thank you very much

Thanks in advance
Charlie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top