Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50094

Change of range in VBA Code

$
0
0
Dear All,
if someone please help me to explain the code, i need to change the cell range like in this the data is in sheet "main" and starting from row A1 to K now what if i need to change the range from A1 to A5 and also fix the coloum to "K" because if i add data to "L" it also tranfer to other sheet.

VB:
Code:

Sub test()
    Dim e, x As String, temp As String
    Application.ScreenUpdating = False
    With Sheets("main").Cells(1).CurrentRegion
        .Parent.AutoFilterMode = False
        temp = .Range("d2").NumberFormat
        x = .Columns("k").Offset(1).Address
        For Each e In Filter(.Parent.Evaluate("transpose(if(countif(offset(" & x & _
            ",0,0,row(1:" & .Rows.Count & "))," & x & ")=1," & x & ",char(2)))"), Chr(2), 0)
            Sheets(e).Range("a4").CurrentRegion.ClearContents
            .AutoFilter 11, e
            .AutoFilter 4, ">=" & Sheets(2).Range("b1"), 1, "<=" & Sheets(2).Range("b2")
            .Copy Sheets(e).Range("a4")
            .AutoFilter
        Next
    End With
    Application.ScreenUpdating = True
End Sub

please feel free to ask if i am unable to explain it correctly.

thanx in advance

Viewing all articles
Browse latest Browse all 50094

Trending Articles