![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Los Angeles, CA
Posts: 752
|
I don't know how to do this but I want to add this to a macro.
In cell a1 there is a date (the rest of the column is blank) and in the column next to it, column b, there is text, about 200 rows. How would I get the date to automatically fill in the cells, when there is text to the right of it? Thanks |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try the following code:
Range("a1").Select Selection.AutoFill Destination:=Range("b1:b200").Offset(0, -1) Change ("b1:b200") to whatever the range is in column B. This will work if the column always the same size.
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Los Angeles, CA
Posts: 752
|
Thanks for the advice, but what if the range changes.
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
You can find the used range in column B. Try the following code:
ColumnBRange = Intersect(ActiveSheet.UsedRange, Columns("B")).Address Range("a1").Select Selection.AutoFill Destination:=Range(ColumnBRange).Offset(0, -1), Type:=xlFillCopy _________________ Hope this helps. Kind regards, Al. [ This Message was edited by: Al Chara on 2002-04-01 13:33 ] |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Los Angeles, CA
Posts: 752
|
Well it kinda worked. It did what it was suppose to but the date changed, from 1/1 to 1/2 to 1/3 etc.
Any ideas how to keep it the same? Thanks |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try the code above, I edited it to suit your needs.
__________________
Kind regards, Al Chara |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Feb 2002
Location: Los Angeles, CA
Posts: 752
|
Thanks for the help it worked great.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|