VBA to autofill date in every other column

blewbot

New Member
Joined
Jun 7, 2011
Messages
14
I need a vba code that will take a date entered in C1.. for example 1/1/11 and autofill the the next date (1/2/11) in E1...and so forth for G1,I1,K1,M1,O1

ive searched and searched and only seem to have found 10 more ways not to accomplish my goal.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try

Code:
Sub FillDate()
Dim j As Double
For j = 5 To 15 Step 2
    Cells(1, j).Value = Cells(1, 3).Value + 0.5 * (j - 2.5)
Next j
End Sub
 
Upvote 0
Thanks for the quick reply.

That looks like it would work, but how do i get it to execute that line of command? when i enter a date in C1, nothing happens to the other cells which i mentioned in the first post.

Sorry, im sure this is simple, but im a self taught Vba Noob.
 
Upvote 0
This may be a silly question, but did you run the macro after entering a date in C1?
 
Upvote 0
Try this: right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim j As Double
If Target.Address(False, False) = "C1" Then
    Application.EnableEvents = False
    For j = 5 To 15 Step 2
        Cells(1, j).Value = Cells(1, 3).Value + 0.5 * (j - 2.5)
    Next j
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,756
Messages
6,132,535
Members
449,733
Latest member
Nameless_

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