• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code to autofill

Aleksandar

New Member
Hi everyone! I have a question. I need help to save time in Excel.
I need to autofill each company name in column D to fill empty space in between different companies. Problem is that there are few hundred different companies and I need to autofill each company name to be listed 7 times since there are 7 months. You can see problem on picture.
 

Attachments

  • VBA Problem.PNG
    VBA Problem.PNG
    9.9 KB · Views: 19
Starting with the cell containing XYZ, select all the cells in that column to the bottom of the table. Press F5, Special…, Blanks, OK.
Before doing anything else, press the = key on the keyboard, then the cursor-up arrow once, then hold the Ctrl key while pressing Enter on the keyboard.
Now select all the cells again, Ctrl+c, then Paste-Special, Values in situ.

Or select your cells first, then run this macro:
Code:
Sub blah()
Set OrigSelection = Selection
Selection.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
OrigSelection.Value = OrigSelection.Value
End Sub
 
Last edited:
Back
Top