Macro auto fill is not workin

Ashkan2016

New Member
Joined
May 8, 2016
Messages
5
Hi all
I am trying to write for my excel .I am begginer and this first time I tred Macro.
I wrote this code
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Application.Worksheets("1").Range("D2").Value = "Completed" Then
      Worksheets("2").Range("C26").Value = Date
   Else
      Worksheets("2").Range("C26").Value = ""
End If
If Application.Worksheets("1").Range("E2").Value = "Completed" Then
      Worksheets("2").Range("D26").Value = Date
   Else
      Worksheets("2").Range("D26").Value = ""
End If
If Application.Worksheets("1").Range("D3").Value = "Completed" Then
      Worksheets("2").Range("C27").Value = Date
   Else
      Worksheets("2").Range("C27").Value = ""
End If
If Application.Worksheets("1").Range("E3").Value = "Completed" Then
      Worksheets("2").Range("D27").Value = Date
   Else
      Worksheets("2").Range("D27").Value = ""
End If
Worksheets("2").Range("C26:D27").Select
Selection.autofill Destination:=Worksheets("2").Range("C26:ZZ52")
End Sub

error 1004;Select method of rang class failed and the line
Worksheets("2").Range("C26:D27").Select
is highlighted
I have no idea what to do ;can you guys help me thanks

Ashkan
Email:rezania.ashkan@gmail.com

</code>
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Selecting and using Autofill will not work that way.
You need to come up with another way of doing this or explain what your wanting to do and maybe I can provide another solution.
 
Upvote 0
And with your sheet change event setup like this with no criteria every time you make any change anywhere on your sheet this event is going to be activated. Which is probable not a good plan.

Since you really did not ask for any help other then the problem with Autofill. I will leave any more comments to a later date if you care to tell us what your trying to do here.
 
Upvote 0
And with your sheet change event setup like this with no criteria every time you make any change anywhere on your sheet this event is going to be activated. Which is probable not a good plan.

Since you really did not ask for any help other then the problem with Autofill. I will leave any more comments to a later date if you care to tell us what your trying to do here.
My manager asked me to make excel file for safty tracking.every one after completing training should be able to go to excel file and record the date of completion .since some people don't know computer very well the fill should give them the option between complete and not complete and if they choose complete the file should record the date.if you can send me your email address I can send you the file. I really appreciate if you help me.I am open to any suggestion and help.
 
Upvote 0
Mr. Excel discourages us from helping people outside of this Forum.
I'm not able to provide you with email address.

Please try to explain in words what your wanting to do.

If the student enters complete into what cell then what cell should be filled in with the date.
And what is the trend. For example is it always one row down or over one row.

And what is this Autofill portion of the script attempting to do.
 
Upvote 0
Mr. Excel discourages us from helping people outside of this Forum.
I'm not able to provide you with email address.

Please try to explain in words what your wanting to do.

If the student enters complete into what cell then what cell should be filled in with the date.
And what is the trend. For example is it always one row down or over one row.

And what is this Auto fill portion of the script attempting to do.
I attached picture of my file.
ecxel%20code.PNG

Sheet1.PNG
Sheet%20structure.PNG
sheet%20graph.PNG
 
Upvote 0
If you read the rules in the forums you have cross-posted in you would know that in most (including this one) allow posting in other forums but you need to post a link to your cross-posts.

There are links to this forums rules and guidelines in my signature block below (Rule 13 is relevant to this and there is a link in that rule explaining the reasons in detail)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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