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

End If without block If

$
0
0
Part of a macro is below. There is an alternative block for 'PN. To get over the problem do I have to put "End if" after " ActiveSheet.Paste" then begin another "If" block? I'd prefer a method of putting both paragraphs within the 1 "IF", just for convenience/ brevity.

'EN
If Range("aaj1") = 1 Then
Range("aai3:aai182").Select
Selection.Copy
Range("k3:aag182").Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Paste

Range("g3:aal182").Select
ActiveWorkbook.Worksheets("NewData").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("NewData").Sort.SortFields.Add Key:=Range( _
"aaj3:aaj182"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("NewData").Sort
.SetRange Range("g3:AAL182")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply

Range("aaj3:aaj32").Select
Selection.Copy
Range("k3:aag32").Select
ActiveSheet.Paste
End If

Viewing all articles
Browse latest Browse all 50199

Trending Articles