Excel and VB6 Questions
Chip,
Thanks for the response. Unfortunately, I'm getting a run time error
on the code for the CopyDestination you gave me. Here is my code:
Dim intRandomNumber As Integer
Dim i, x, y, z, intCounter As Integer
Dim strStart, strEnd, strSheet1, strSheet2 As String
intRandomNumber = CLng(txtRandomNumber)
intCounter = 1
x = CLng(txtStartingNumber.Text)
y = CLng(txtEndingNumber.Text)
z = CLng(txtRandomNumber.Text)
strSheet1 = txtOriginalSheetName.Text
strSheet2 = txtSampleSheetName.Text
strStart = txtStartingColumn.Text
strEnd = txtEndingColumn.Text
Dim xlApp As New Excel.Application
Dim xlBook As New Excel.Workbook
Dim xlSheet1 As New Excel.Worksheet
Dim xlSheet2 As New Excel.Worksheet
Set xlBook = xlApp.Workbooks.Open(txtFileName)
Set xlSheet1 = xlBook.Worksheets(strSheet1)
Set xlSheet2 = xlBook.Worksheets.Add
xlSheet2.Name = strSheet2
For i = x To y Step z
Worksheets(strSheet1).Range(strStart & CStr(x) & ":" & strEnd &
CStr(x)).CopyDestination = Worksheets(strSheet2).Range(strStart &
CStr(intCounter) & ":" & strEnd & CStr(intCounter))
intCounter = intCounter + 1
Next
xlBook.Close
xlApp.Quit
I even tried running what I am trying to do in the immediate window,
same error. This was my code the
Worksheets(strSheet1).Range("A5:W5").CopyDestinati on =
Worksheets(strSheet2).Range("A1") and still a no-go.
Any suggestions?
Thanks
Cen
|