ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compile Error (https://www.excelbanter.com/excel-programming/275441-compile-error.html)

Markus

Compile Error
 
When I use the following code I receive an error message
that says Compile Error: Statements and labels invalid
between Select Case and first Case. The word QA is
highlighted in yellow after the word Set. What am I
missing or what am I doing incorrectly? Your time is
appreciated.

Private Sub Up1_Click()
Select Case LB1.ListIndex
Dim QA As Worksheet
Dim SourceRows As Variant
Dim DestRows As Variant
Dim I As Long

Set QA = Worksheets("QA" & LB1.ListIndex + 1)

SourceRows = Array(6, 9, 11, 12, 13, 14, 16)
DestRows = Array(13, 14, 31, 49, 78, 96, 114)

Range("C5").Value = QA.Range("B4").Value
Range("C6").Value = QA.Range("E4").Value

For I = LBound(SourceRows) To Unbound(SourceRows)
'copy all 12 cells from source row column D
'to destination row column C
Cells(DestRows(I), "C").Resize(1, 12).Value = QA.Cells
(SourceRows(I), "D").Resize(1, 12).Value
Next I
End Sub

Tom Ogilvy

Error Cont....
 
It is Ubound, not Unbound

Regards,
Tom Ogilvy

"Markus" wrote in message
...
Thanks for all your help. I deleted the Select case line
from the command. Although now when the the command is run
i get a new compile error. Sub or Function not Defined.
With the highlight on the word Unbound
-----Original Message-----
You don't need the select case. If I left it in there,

it was an omission
to not delete it

Private Sub Up1_Click()
Dim QA As Worksheet
Dim SourceRows As Variant
Dim DestRows As Variant
Dim I As Long

Set QA = Worksheets("QA" & LB1.ListIndex + 1)

SourceRows = Array(6, 9, 11, 12, 13, 14, 16)
DestRows = Array(13, 14, 31, 49, 78, 96, 114)

Range("C5").Value = QA.Range("B4").Value
Range("C6").Value = QA.Range("E4").Value

For I = LBound(SourceRows) To Unbound(SourceRows)
'copy all 12 cells from source row column D
'to destination row column C
Cells(DestRows(I), "C").Resize(1, 12).Value = _
QA.Cells(SourceRows(I), "D").Resize(1, 12).Value
Next I
End Sub

--
Regards,
Tom Ogilvy

"Markus" wrote in message
...
When I use the following code I receive an error message
that says Compile Error: Statements and labels invalid
between Select Case and first Case. The word QA is
highlighted in yellow after the word Set. What am I
missing or what am I doing incorrectly? Your time is
appreciated.

Private Sub Up1_Click()
Select Case LB1.ListIndex
Dim QA As Worksheet
Dim SourceRows As Variant
Dim DestRows As Variant
Dim I As Long

Set QA = Worksheets("QA" & LB1.ListIndex + 1)

SourceRows = Array(6, 9, 11, 12, 13, 14, 16)
DestRows = Array(13, 14, 31, 49, 78, 96, 114)

Range("C5").Value = QA.Range("B4").Value
Range("C6").Value = QA.Range("E4").Value

For I = LBound(SourceRows) To Unbound(SourceRows)
'copy all 12 cells from source row column D
'to destination row column C
Cells(DestRows(I), "C").Resize(1, 12).Value =

QA.Cells
(SourceRows(I), "D").Resize(1, 12).Value
Next I
End Sub



.





All times are GMT +1. The time now is 01:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com