ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Splitting a Procedure (https://www.excelbanter.com/excel-programming/275330-re-splitting-procedure.html)

Myrna Larson[_2_]

Splitting a Procedure
 
Typo, Tom. Should be

For i = 0 To 6

not 7. But I prefer Lbound and UBound, to avoid errors if there's an Option Base 1 statement at
the top of the module.

On Tue, 26 Aug 2003 11:33:53 -0400, "Tom Ogilvy" wrote:

Private Sub Up1_Click()

Dim i as long, idex as long

Dim rngSource as Range, rngDest as Range

Dim sName as String

Dim varr as variant, varr1 as variant
idex = LB1.ListIndex+1

SName = "QA"&idex
Range("C5").Value = Worksheets(sName).Range("B4").Value
Range("C6").Value = Worksheets(sName).Range("E4").Value
varr = Array(13,14,31,49,78,96,114)

varr1 = Array(6,9,11,12,13,14,16)

for i = 0 to 7

set rngSource = worksheets(sName).Cells(varr1(i),4).Resize(1,12)

set rngDest = Cells(varr(i),3).Resize(1,12)

rngDest.Value = rngSource.value

Next

End Sub



Should be a little more manageable.



Tom Ogilvy

Splitting a Procedure
 
Thanks for the typo correction. I usually use Lbound and Ubound as well.

Regards,
Tom Ogilvy


"Myrna Larson" wrote in message
...
Typo, Tom. Should be

For i = 0 To 6

not 7. But I prefer Lbound and UBound, to avoid errors if there's an

Option Base 1 statement at
the top of the module.

On Tue, 26 Aug 2003 11:33:53 -0400, "Tom Ogilvy" wrote:

Private Sub Up1_Click()

Dim i as long, idex as long

Dim rngSource as Range, rngDest as Range

Dim sName as String

Dim varr as variant, varr1 as variant
idex = LB1.ListIndex+1

SName = "QA"&idex
Range("C5").Value = Worksheets(sName).Range("B4").Value
Range("C6").Value = Worksheets(sName).Range("E4").Value
varr = Array(13,14,31,49,78,96,114)

varr1 = Array(6,9,11,12,13,14,16)

for i = 0 to 7

set rngSource = worksheets(sName).Cells(varr1(i),4).Resize(1,12)

set rngDest = Cells(varr(i),3).Resize(1,12)

rngDest.Value = rngSource.value

Next

End Sub



Should be a little more manageable.






All times are GMT +1. The time now is 06:26 PM.

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