LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Sheets(MyArr(i)).Range("L2:L20") to a variable range of column L

I have a couple attempts commented out trying to make a variable range for column L for each sheet in the array.

The hardcoded range works okay, however.

Thanks.
Howard

Sub Greater_Than_Copy()

Dim MyArr As Variant
Dim c As Range
Dim i As Long
Dim rngA As Range, lrMA As Range
Dim lrCl As Long

lrCl = Sheets("Sheet5").Cells(Rows.Count, 1).End(xlUp).Row
With Sheets("Sheet5").Range("A1:L" & lrCl)
.ClearContents
End With

MyArr = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")

Application.ScreenUpdating = False

For i = LBound(MyArr) To UBound(MyArr)

With Sheets(MyArr(i))

'Set rngA = Range("L2", Range("L2").End(xlDown))
'Set rngA = Sheets(MyArr(i)).Range("L2", Range("L2").End(xlDown))

Set rngA = Sheets(MyArr(i)).Range("L2:L20")

For Each c In rngA
If c.Value 0 Then
c.Offset(, -11).Resize(1, 12).Copy Sheets("Sheet5").Range("A" & Rows.Count) _
.End(xlUp)(2)
End If
Next 'c

End With
Next 'i

Application.ScreenUpdating = True
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range("C100:D200").Select with variable names Fan924 Excel Programming 2 October 15th 07 03:54 PM
Range("B2").AutoFill Destination:=Range("GX1", ActiveCell) ... Fails but why? [email protected] Excel Programming 2 March 13th 07 12:10 PM
Range("B2").AutoFill Destination:=Range("GX1", ActiveCell) ... Fails but why? [email protected] Excel Programming 0 March 13th 07 02:22 AM
Range("B2").AutoFill Destination:=Range("GX1", ActiveCell) ... Fails but why? [email protected] Excel Programming 0 March 13th 07 02:16 AM
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM


All times are GMT +1. The time now is 03:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"