Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / March 2008

Tip: Looking for answers? Try searching our database.

code not working with auto fill

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
forcast - 24 Mar 2008 06:16 GMT
I have a code working very well when I fill cells manually, but when I use
auto fill the code stops working as if it does not exist . how  can I  make
the code work with the auto fill.  
Thank you.
OssieMac - 24 Mar 2008 07:51 GMT
Don't really understand the question. Do you mean that you are recording code
but the recorded code does not work with Autofill?

Signature

Regards,

OssieMac

> I have a code working very well when I fill cells manually, but when I use
> auto fill the code stops working as if it does not exist . how  can I  make
> the code work with the auto fill.  
> Thank you.
forcast - 24 Mar 2008 08:37 GMT
Dear OssieMac
Thank you for replying my problem is :
This the code
If Target.Column = 3 Then
   If Selection.Count > 1 Then Exit Sub
   Target.Offset(0, -1).Formula = "=Row()-1"
   If Target = "" Then Target.Offset(0, -1) = ""
End If
End Sub
Now if you fill C1, C2 manually with number 1 ,2 you can see the result on
B1,B2 it is 0,1 now everything is OK so far but if you auto fill
C3,C4,C5……..you can not see any result on B3,B4,B5……….also if you make C7 =
F4 and you fill F4 with any number say 10 you can see your number 10
automatically on C7 but no result on B7 which mean the code is not respond .
Thank you    
forcast

> Don't really understand the question. Do you mean that you are recording code
> but the recorded code does not work with Autofill?
[quoted text clipped - 3 lines]
> > the code work with the auto fill.  
> > Thank you.
Dave Peterson - 24 Mar 2008 13:23 GMT
Maybe...

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

   Dim myRng As Range
   Dim myCell As Range
   
   Set myRng = Intersect(Target, Me.Range("C:C"))
   
   If myRng Is Nothing Then
       Exit Sub
   End If
   
   For Each myCell In myRng.Cells
       If myCell.Value = "" Then
           myCell.Offset(0, -1).Value = ""
       Else
           myCell.Offset(0, -1).Formula = "=Row()-1"
       End If
   Next myCell
End Sub

> Dear OssieMac
>  Thank you for replying my problem is :
[quoted text clipped - 25 lines]
> > > the code work with the auto fill.
> > > Thank you.

Signature

Dave Peterson

forcast - 24 Mar 2008 15:00 GMT
Dear Dave Peterson
Thank you very much It is excellent solution .

Regards
Forcast  

> Maybe...
>
[quoted text clipped - 48 lines]
> > > > the code work with the auto fill.
> > > > Thank you.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.