macro to autofill data in the same column

ockyoz

New Member
Joined
May 25, 2016
Messages
10
Hi guys, often I have data like the following:

rose





Lilly





tulip

and I need to autofill the cells in the column (got thousands of names and the position of the names is always different) so I have been double clicking at the lower right corner of the cell every time but it's time consuming. Could a macro help me out??
Cheers
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Assuming "rose" is in A2 :
- Select from A2 to the last cell to be filled.
- Go to SpecialCells/Blanks
- Type =A2
- Press Ctrl+Enter
- Select column A and Copy/PasteSpecial-Values
 
Upvote 0
Hi guys, often I have data like the following:

rose





Lilly





tulip

and I need to autofill the cells in the column (got thousands of names and the position of the names is always different) so I have been double clicking at the lower right corner of the cell every time but it's time consuming. Could a macro help me out??
Cheers

Here's another way, using macro:
Code:
Sub a1009435()

Dim vr
Dim i As Long
Dim rr As Long

rr = Range("A" & Rows.count).End(xlUp).row
vr = Range("A1:A" & rr)

For i = 2 To rr
     If vr(i, 1) = vbNullString Then vr(i, 1) = vr(i - 1, 1)
Next i
  
Range("A1").Resize(rr, 1).Value = vr
  
End Sub
 
Upvote 0
Here's another way, using macro:
Code:
Sub a1009435()

Dim vr
Dim i As Long
Dim rr As Long

rr = Range("A" & Rows.count).End(xlUp).row
vr = Range("A1:A" & rr)

For i = 2 To rr
     If vr(i, 1) = vbNullString Then vr(i, 1) = vr(i - 1, 1)
Next i
  
Range("A1").Resize(rr, 1).Value = vr
  
End Sub

Or you could use the macro recorder to record the steps in post #2.
 
Upvote 0
Have tried recording a macro but it never works the next time as the position of the words always changes...
 
Upvote 0
This script worked for me. If you only have three words it's going to stop after the second word. And if there are only three values it's only continues if there are more words below the third word.
Cheers, it works (kinda) but it stops at the third word...
 
Upvote 0
Cheers, it works (kinda) but it stops at the third word...
You mean it stops at the last word, right?
Well, for the last word we don't know how many blank cell below it you want to fill.
So you have to do it manually.
 
Upvote 0
Have tried recording a macro but it never works the next time as the position of the words always changes...

Record the macro, post the code and you will learn how to tweak the macro so that it works on any number of rows.
 
Upvote 0
You mean it stops at the last word, right?
Well, for the last word we don't know how many blank cell below it you want to fill.
So you have to do it manually.

Unless some other column can be used to find the last row.
 
Upvote 0

Forum statistics

Threads
1,224,815
Messages
6,181,136
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top