alu
11-07-2011, 03:28 AM
I have a large spreadsheed like the one attached.
I wish to fill the ID & Name to occupy the blank rows to the next name.
I can do this at the moment using key combinations. Starting in cell A2 I use:
Ctrl+Shift+Right Arrow
Ctrl+Shift+Down Arrow
Shift+Up Arrow
Ctrl+D
Ctrl+Down Arrow
then loop back to begininng...
When I try and record this I end up with the following code:
Sub Macro1()
'
' Macro1 Macro
'
'
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range("A2:B9").Select
Selection.FillDown
Selection.End(xlDown).Select
End Sub
But when I run it to fill the names for the entire spreadsheet it keeps going back to the first example I used and no further.
How can I ammend this code so it fills the name and ID down until the change in name and ID then repeats process again and again?
I think it's something to do with the code below, but i'm not too sure.
Range(ActiveCell, ActiveCell.End(xlToRight)).Copy
Thanks in advance
I wish to fill the ID & Name to occupy the blank rows to the next name.
I can do this at the moment using key combinations. Starting in cell A2 I use:
Ctrl+Shift+Right Arrow
Ctrl+Shift+Down Arrow
Shift+Up Arrow
Ctrl+D
Ctrl+Down Arrow
then loop back to begininng...
When I try and record this I end up with the following code:
Sub Macro1()
'
' Macro1 Macro
'
'
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range("A2:B9").Select
Selection.FillDown
Selection.End(xlDown).Select
End Sub
But when I run it to fill the names for the entire spreadsheet it keeps going back to the first example I used and no further.
How can I ammend this code so it fills the name and ID down until the change in name and ID then repeats process again and again?
I think it's something to do with the code below, but i'm not too sure.
Range(ActiveCell, ActiveCell.End(xlToRight)).Copy
Thanks in advance