Sign in to follow this  
Followers 0
Tonych

Copy Excel worksheet

5 posts in this topic

I have a Excel macro:

n = 2

if t > 25 Then

For i = 1 To Int(t / 25)

Sheets(2).Select

Sheets(2).Copy After:=Sheets(n)

n = n + 1

Sheets(n).Select

Sheets(n).Name = "Sheet" & CStr(n)

Next i

End If

There is a form in Sheet2, I need to copy it so that I can put 25 datas in every worksheet.

I want to make it in AutoIt, please anyone could give me some advice! Thanks in advance!

Share this post


Link to post
Share on other sites



I'm not really sure what you're asking. Could you explain in a little more detail and maybe someone can help you.

Share this post


Link to post
Share on other sites

Thanks for you concern! I am sorry I did not tell it clearly. The main problem is that I want to translate the VBA macro:

Sheets(2).Copy After:=Sheets(2) into AutoIt. Thanks in advance!

Share this post


Link to post
Share on other sites

why not ?

1.Open excel

2.Open the file

3.Import the VBA macro

4.Run it

Share this post


Link to post
Share on other sites

Thanks for you concern! I am sorry I did not tell it clearly. The main problem is that I want to translate the VBA macro:

Sheets(2).Copy After:=Sheets(2) into AutoIt. Thanks in advance!

Tonych, try use positional notation of argument list:

Worksheet.Copy(Before, After)

and «Default» AutoIt-keyword for optional argument.

Example code:

Local $objExcel
Local $objWorkbook
Local $objWorksheet

$objExcel = ObjCreate("Excel.Application")
$objExcel.Visible = True
$objWorkbook = $objExcel.Workbooks.Add()
$objWorksheet = $objWorkbook.Worksheets(1)

; Mark this worksheet by text
$objWorksheet.Cells(1,1).Value = "Example"
$objWorksheet.Name = "Example"

; Add some worksheets
$objWorkbook.Worksheets.Add
$objWorkbook.Worksheets.Add
$objWorkbook.Worksheets.Add
$objWorkbook.Worksheets.Add
$objWorkbook.Worksheets.Add
$objWorkbook.Worksheets.Add

; Copy this worksheet
$objWorksheet.Copy(Default, $objWorkbook.Worksheets(2))

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0