Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Auto-filling VB Script Code for Excel

Reply
 
Old 08-29-2008   #1 (permalink)
Pegasus \(MVP\)


 
 

Auto-filling VB Script Code for Excel

The following Excel macro will auto-fill the cells G1:G6 based on the
contents of the cells G1:G2:
Range("G1:G2").Select
Range("G2").Activate
Selection.AutoFill Destination: = Range("G1:G6"), Type: = xlFillDefault

I need to perform the same operation with a pure VB Script. Is it possible?
If yes, how?



My System SpecsSystem Spec
Old 08-29-2008   #2 (permalink)
Dave Patrick


 
 

Re: Auto-filling VB Script Code for Excel

Option Explicit
Const xlFillDefault = 0
Dim filePath, oExcel, oSheet

filePath = "c:\Test.xls"
Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Open(filepath)
Set oSheet = oExcel.ActiveWorkbook.Worksheets(1)
osheet.Range("G1:G2").Select
osheet.Range("G2").Activate
oExcel.Selection.AutoFill oExcel.Range("G1:G6"), xlFillDefault
oExcel.ActiveWorkbook.Save
oExcel.ActiveWorkbook.Close
set oSheet = Nothing
Set oExcel = Nothing

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Pegasus (MVP)" wrote:
Quote:

> The following Excel macro will auto-fill the cells G1:G6 based on the
> contents of the cells G1:G2:
> Range("G1:G2").Select
> Range("G2").Activate
> Selection.AutoFill Destination: = Range("G1:G6"), Type: = xlFillDefault
>
> I need to perform the same operation with a pure VB Script. Is it
> possible? If yes, how?
>
>
My System SpecsSystem Spec
Old 08-30-2008   #3 (permalink)
Pegasus \(MVP\)


 
 

Re: Auto-filling VB Script Code for Excel


"Dave Patrick" <DSPatrick@xxxxxx> wrote in message
news:erqdTMlCJHA.4700@xxxxxx
Quote:

> Option Explicit
> Const xlFillDefault = 0
> Dim filePath, oExcel, oSheet
>
> filePath = "c:\Test.xls"
> Set oExcel = CreateObject("Excel.Application")
> oExcel.Workbooks.Open(filepath)
> Set oSheet = oExcel.ActiveWorkbook.Worksheets(1)
> osheet.Range("G1:G2").Select
> osheet.Range("G2").Activate
> oExcel.Selection.AutoFill oExcel.Range("G1:G6"), xlFillDefault
> oExcel.ActiveWorkbook.Save
> oExcel.ActiveWorkbook.Close
> set oSheet = Nothing
> Set oExcel = Nothing
>
> --
>
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
Great - works like a charm!


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Auto Filling Addresses Vista mail
start word, excel from script VB Script
Re: How to do something in an VBS script for all worksheets of an Excel file? VB Script
Auto filling in of email addresses ? Vista mail
Auto filling email recipient address Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46