PC Review


Reply
Thread Tools Rate Thread

Autofill formula on non-Active sheet

 
 
Greg Lovern
Guest
Posts: n/a
 
      4th Dec 2006
Is it possible to autofill formulas on a worksheet other than the
active sheet?

For example, this works fine if Sheet1 is active, but returns an error
if not:

ThisWorkbook.Worksheets("Sheet1").Range("A1").AutoFill
Range("A1:A10000"), xlFillDefault

I need to autofill formulas that a user will enter, and at design time
I have no knowledge of what the formula will be. It would be a lot of
work to parse out the various parts of a large, complex formula so that
absolute references & relative references are each autofilled
correctly.

Do I have to do something like this, which helps but isn't ideal?

Dim fIsNotActiveSheet As Boolean
Dim shAutoFill As Worksheet
Dim shActive As Worksheet

Application.ScreenUpdating = False

Set shAutoFill = ThisWorkbook.Worksheets("Sheet1")

If shAutoFill.Name <> ActiveSheet.Name Then
fIsNotActiveSheet = True
Set shActive = ActiveSheet
shAutoFill.Activate
End If

shAutoFill.Range("A1").AutoFill Range("A1:A10000"), xlFillDefault

If fIsNotActiveSheet Then
shActive.Activate
End If

Application.ScreenUpdating = True




Thanks,

Greg

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      4th Dec 2006
Fully qualify that range:

ThisWorkbook.Worksheets("Sheet1").Range("A1").AutoFill _
Thisworkbook.worksheets("Sheet1").Range("A1:A10000"), xlFillDefault

Or

with ThisWorkbook.Worksheets("Sheet1")
.Range("A1").AutoFill _
.Range("A1:A10000"), xlFillDefault
end with



Greg Lovern wrote:
>
> Is it possible to autofill formulas on a worksheet other than the
> active sheet?
>
> For example, this works fine if Sheet1 is active, but returns an error
> if not:
>
> ThisWorkbook.Worksheets("Sheet1").Range("A1").AutoFill
> Range("A1:A10000"), xlFillDefault
>
> I need to autofill formulas that a user will enter, and at design time
> I have no knowledge of what the formula will be. It would be a lot of
> work to parse out the various parts of a large, complex formula so that
> absolute references & relative references are each autofilled
> correctly.
>
> Do I have to do something like this, which helps but isn't ideal?
>
> Dim fIsNotActiveSheet As Boolean
> Dim shAutoFill As Worksheet
> Dim shActive As Worksheet
>
> Application.ScreenUpdating = False
>
> Set shAutoFill = ThisWorkbook.Worksheets("Sheet1")
>
> If shAutoFill.Name <> ActiveSheet.Name Then
> fIsNotActiveSheet = True
> Set shActive = ActiveSheet
> shAutoFill.Activate
> End If
>
> shAutoFill.Range("A1").AutoFill Range("A1:A10000"), xlFillDefault
>
> If fIsNotActiveSheet Then
> shActive.Activate
> End If
>
> Application.ScreenUpdating = True
>
> Thanks,
>
> Greg


--

Dave Peterson
 
Reply With Quote
 
Greg Lovern
Guest
Posts: n/a
 
      5th Dec 2006
Thanks! (blush...)

Greg


Dave Peterson wrote:
> Fully qualify that range:
>
> ThisWorkbook.Worksheets("Sheet1").Range("A1").AutoFill _
> Thisworkbook.worksheets("Sheet1").Range("A1:A10000"), xlFillDefault
>
> Or
>
> with ThisWorkbook.Worksheets("Sheet1")
> .Range("A1").AutoFill _
> .Range("A1:A10000"), xlFillDefault
> end with
>
>
>
> Greg Lovern wrote:
> >
> > Is it possible to autofill formulas on a worksheet other than the
> > active sheet?
> >
> > For example, this works fine if Sheet1 is active, but returns an error
> > if not:
> >
> > ThisWorkbook.Worksheets("Sheet1").Range("A1").AutoFill
> > Range("A1:A10000"), xlFillDefault
> >
> > I need to autofill formulas that a user will enter, and at design time
> > I have no knowledge of what the formula will be. It would be a lot of
> > work to parse out the various parts of a large, complex formula so that
> > absolute references & relative references are each autofilled
> > correctly.
> >
> > Do I have to do something like this, which helps but isn't ideal?
> >
> > Dim fIsNotActiveSheet As Boolean
> > Dim shAutoFill As Worksheet
> > Dim shActive As Worksheet
> >
> > Application.ScreenUpdating = False
> >
> > Set shAutoFill = ThisWorkbook.Worksheets("Sheet1")
> >
> > If shAutoFill.Name <> ActiveSheet.Name Then
> > fIsNotActiveSheet = True
> > Set shActive = ActiveSheet
> > shAutoFill.Activate
> > End If
> >
> > shAutoFill.Range("A1").AutoFill Range("A1:A10000"), xlFillDefault
> >
> > If fIsNotActiveSheet Then
> > shActive.Activate
> > End If
> >
> > Application.ScreenUpdating = True
> >
> > Thanks,
> >
> > Greg

>
> --
>
> Dave Peterson


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Copy/autofill Text from sheet to sheet if meets criteria Joyce Microsoft Excel Misc 0 20th Nov 2008 11:05 PM
Copy from active sheet and paste into new sheet using info from cell in active Ingve Microsoft Excel Programming 3 23rd Jan 2006 09:57 PM
Autofill information from Sheet 1 to Sheet 2? =?Utf-8?B?S3Jpc3R5?= Microsoft Excel Programming 1 3rd Oct 2005 07:26 PM
Creating absolute references including active sheet name in the formula Maria J-son Microsoft Excel Programming 4 10th May 2005 08:41 AM
Autofill A Non Contiguous Formula/Series From Another Sheet?? Simon Microsoft Excel Worksheet Functions 0 16th Jul 2003 04:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:11 AM.