I am failing miserably to make use of the Rows Count function!!
Everything I have tried to date has ended up with one error or another!!!
At the moment I have 2 codes, one that gets me what I want to achieve, in a roundabout way, other is floored!!
But, BOTH ultimately require a Row Count
What I have so far is:-
1st code works better for me AS IT STANDS because it DOES NOT rely on a Row Count, but filter values are ALSO pasted into "AM:AP", which then require clearing!!
What I THINK I need is a Row Count of the “UsedRngT”, then ONLY insert/shift down the values into Range("AK" & FrowAr + 2 & ":AL" & FrowAr + 2)
but then use the Row Count result to insert THAT given number of blank rows into Range("AM" & FrowAr + 2 & ":AP" & FrowAr +2)?
2nd code works to a fashion, BUT it is floored!!
Because, "Range("AK" & FrowAr + 2 & ":AL" & FrowAr + 2) " is a dynamic range, therefore I don’t know how many rows to ACTUALLY insert into “Range("AM" & FrowAr + 2 & ":AP" & FrowAr + 2).”
Everything I have tried to date has ended up with one error or another!!!
At the moment I have 2 codes, one that gets me what I want to achieve, in a roundabout way, other is floored!!
But, BOTH ultimately require a Row Count
What I have so far is:-
1st code works better for me AS IT STANDS because it DOES NOT rely on a Row Count, but filter values are ALSO pasted into "AM:AP", which then require clearing!!
What I THINK I need is a Row Count of the “UsedRngT”, then ONLY insert/shift down the values into Range("AK" & FrowAr + 2 & ":AL" & FrowAr + 2)
but then use the Row Count result to insert THAT given number of blank rows into Range("AM" & FrowAr + 2 & ":AP" & FrowAr +2)?
VBA Code:
Set UsedRngT = Range("AK" & Frow & ":AL" & Lrow) 'UsedRngT is the ACTUAL USED range of "TEMP" range,
Set rngA = Range("AK:AK").Find(what:="Ar Sub Total", LookIn:=xlValues, LookAt:=xlWhole)
FrowAr = rngA.Row
Set rngCopy = UsedRngT
rngCopy.Copy
Range("AK" & FrowAr + 2 & ":AP" & FrowAr + 2).Insert Shift:=xlShiftDown ' BUT filter values are ALSO pasted to "AM:AP"
Set rngAA = Range("AK:AK").Find(what:="Ar Total", LookIn:=xlValues, LookAt:=xlWhole)
LrowAr = rngAA.Row
Range("AM" & FrowAr + 2 & ":AP" & LrowAr - 1).Clear ' This just clears the unwanted filter values from "AM:AP" range
Because, "Range("AK" & FrowAr + 2 & ":AL" & FrowAr + 2) " is a dynamic range, therefore I don’t know how many rows to ACTUALLY insert into “Range("AM" & FrowAr + 2 & ":AP" & FrowAr + 2).”
VBA Code:
Set UsedRngT = Range("AK" & Frow & ":AL" & Lrow) 'UsedRngT is the ACTUAL used range of "TEMP" range,
Set rngA = Range("AK:AK").Find(what:="Ar Sub Total", LookIn:=xlValues, LookAt:=xlWhole)
FrowAr = rngA.Row
Set rngAA = Range("AK:AK").Find(what:="Ar Total", LookIn:=xlValues, LookAt:=xlWhole)
LrowAr = rngAA.Row
Set rngCopy = UsedRng
rngCopy.Copy
Range("AK" & FrowAr + 2 & ":AL" & FrowAr + 2).Insert Shift:=xlShiftDown
' This is adding 3 rows to Range("AM" & FrowAr + 2 & ":AP" & FrowAr + 2), but it could require +/- untold number of rows
Range("AM" & FrowAr + 2 & ":AP" & FrowAr + 2).Insert Shift:=xlShiftDown
Range("AM" & FrowAr + 2 & ":AP" & FrowAr + 2).Insert Shift:=xlShiftDown
Range("AM" & FrowAr + 2 & ":AP" & FrowAr + 2).Insert Shift:=xlShiftDown