Lacherlich
New Member
- Joined
- Dec 2, 2014
- Messages
- 12
Hi
I know this question has been asked in many guises, but the answers don't seem to help and are all specific to the question.
Basically, I am copying data from varying spread sheets into one worksheet. Each time I paste the data into the spread sheet I want to label each data set depending on which sheet I copied it from.
I.E there is a column where I would label the data from one spreadie as '20' for example.
I am having trouble though to get the VBA to fill down the column next to the copied data so all cells are labelled as '20'.
The vba I tried is below, but not complete:
Sub endcellselect()
Range("c1").End(xlDown).Select (this was my attempt to highlight the row of the last blank cell in the label column)Dim d As String
d = ActiveCell.Row
Range("d1").End(xlDown).Offset(1, 0).Select (this was to highlight the first blank cell in the column so I could then select the range to ='20')Dim c As String
c = ActiveCell.Row
Range("d" & c).Select
Selection.Value = 20
Selection.AutoFill Destination:=Range("activecell:D & d")
Range("D3:D6").Select
Range(ActiveCell, ActiveCell & d & "").End(xlDown).Value = 20
Hmm, I hope that kinda makes sense what im trying to achieve? Any help would be great,
Thanks
I know this question has been asked in many guises, but the answers don't seem to help and are all specific to the question.
Basically, I am copying data from varying spread sheets into one worksheet. Each time I paste the data into the spread sheet I want to label each data set depending on which sheet I copied it from.
I.E there is a column where I would label the data from one spreadie as '20' for example.
I am having trouble though to get the VBA to fill down the column next to the copied data so all cells are labelled as '20'.
The vba I tried is below, but not complete:
Sub endcellselect()
Range("c1").End(xlDown).Select (this was my attempt to highlight the row of the last blank cell in the label column)Dim d As String
d = ActiveCell.Row
Range("d1").End(xlDown).Offset(1, 0).Select (this was to highlight the first blank cell in the column so I could then select the range to ='20')Dim c As String
c = ActiveCell.Row
Range("d" & c).Select
Selection.Value = 20
Selection.AutoFill Destination:=Range("activecell:D & d")
Range("D3:D6").Select
Range(ActiveCell, ActiveCell & d & "").End(xlDown).Value = 20
Hmm, I hope that kinda makes sense what im trying to achieve? Any help would be great,
Thanks