beginvbaanalyst
Board Regular
- Joined
- Jan 28, 2020
- Messages
- 141
- Office Version
- 365
- Platform
- Windows
I'm trying to figure out how to use a formula within VBA but stop at an unselected amount of range. Basically just read until there's nothing after the last filled cell
Where is a good example of this? I have the Macro Recorder Code but want to condense it. What tags should I be using for these posts?
What exactly does this mean? =COUNTIFS(C[-9],RC[-2],C[-5],""X"")"
Provided below is the Macro Recorder
ActiveSheet.Range("$I$2:$I$601").RemoveDuplicates Columns:=1, Header:=xlNo 'Removes Duplicate Values from Selected Range
Range("J2").Select 'Selected Range Column J, Row Two ("J2")
Application.CutCopyMode = False 'Leaving Copy/Paste Mode
ActiveCell.FormulaR1C1 = "=COUNTIF(C[-8],RC[-1])" 'Formula for Count If
Range("J2").Select 'Selection for Formula ("J2")
Selection.AutoFill Destination:=Range("J2:J2600") 'Formula COuntif for selected Range ("J2:J2600")
Range("J2:J2600").Select 'Pasted Countif Formula within Selected Range ("J2:J2600")
Range("K2").Select 'Selected Range ("K2")
ActiveCell.FormulaR1C1 = "=COUNTIFS(C[-9],RC[-2],C[-5],""X"")"
Range("K2").Select
Selection.AutoFill Destination:=Range("K2:K26")
Range("K2:K26").Select
Range("L2").Select
ActiveCell.FormulaR1C1 = "=COUNTIFS(C[-10],RC[-3],C[-9],""10011202"")"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L26")
Range("L2:L26").Select
Range("M2").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS(C[-11],RC[-4],C[-7],""X"",C[-10],""10011202"")"
Range("M2").Select
Selection.AutoFill Destination:=Range("M2:M26")
Range("M2:M26").Select
Range("M4").Select
End Sub
Where is a good example of this? I have the Macro Recorder Code but want to condense it. What tags should I be using for these posts?
What exactly does this mean? =COUNTIFS(C[-9],RC[-2],C[-5],""X"")"
Provided below is the Macro Recorder
ActiveSheet.Range("$I$2:$I$601").RemoveDuplicates Columns:=1, Header:=xlNo 'Removes Duplicate Values from Selected Range
Range("J2").Select 'Selected Range Column J, Row Two ("J2")
Application.CutCopyMode = False 'Leaving Copy/Paste Mode
ActiveCell.FormulaR1C1 = "=COUNTIF(C[-8],RC[-1])" 'Formula for Count If
Range("J2").Select 'Selection for Formula ("J2")
Selection.AutoFill Destination:=Range("J2:J2600") 'Formula COuntif for selected Range ("J2:J2600")
Range("J2:J2600").Select 'Pasted Countif Formula within Selected Range ("J2:J2600")
Range("K2").Select 'Selected Range ("K2")
ActiveCell.FormulaR1C1 = "=COUNTIFS(C[-9],RC[-2],C[-5],""X"")"
Range("K2").Select
Selection.AutoFill Destination:=Range("K2:K26")
Range("K2:K26").Select
Range("L2").Select
ActiveCell.FormulaR1C1 = "=COUNTIFS(C[-10],RC[-3],C[-9],""10011202"")"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L26")
Range("L2:L26").Select
Range("M2").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS(C[-11],RC[-4],C[-7],""X"",C[-10],""10011202"")"
Range("M2").Select
Selection.AutoFill Destination:=Range("M2:M26")
Range("M2:M26").Select
Range("M4").Select
End Sub