excelNewbie22
Well-known Member
- Joined
- Aug 4, 2021
- Messages
- 534
- Office Version
- 365
- Platform
- Windows
hi,
i asked the same here:
macro which can change the inside of a formula
but when i tried to apply it in different cells, with try and error,
i managed partially
i need to subtract 1 from:
to
with the macro peter helped me in the mention thread
and the same to the neighboring cells
at: BV684608
from: =COUNTIF($CF$684608:$CF$734608,CU684694)
to: =COUNTIF($CF$684608:$CF$734608,CU684693)
at: BW684608
from: =SUM(COUNTIF($BZ$684608:$CE$784608,CV684694:DA684694))
to: =SUM(COUNTIF($BZ$684608:$CE$784608,CV684693:DA684693))
and last one:
at: BX684608
from: =SUM(COUNTIF($CG$684608:$CL$734608,CV684694:DA684694))
to: =SUM(COUNTIF($CG$684608:$CL$734608,CV684693:DA684693))
it would be great helped if someone can also explain this bit here:
so i can, if needed in the future, edit it to my needs,
also, can it be all in one macro?
i asked the same here:
macro which can change the inside of a formula
but when i tried to apply it in different cells, with try and error,
i managed partially
i need to subtract 1 from:
Excel Formula:
=COUNTIF($BY$684608:$BY$784608,CU684694)
Excel Formula:
=COUNTIF($BY$684608:$BY$784608,CU684693)
VBA Code:
Sub Change_Formula()
Dim Bits As Variant
With Range("BU684608")
Bits = Split(.Formula, ":")
.Formula2 = Left(Bits(0), 2) & Mid(Bits(0), 3) - 1 & ":" & Bits(1)
End With
End Sub
and the same to the neighboring cells
at: BV684608
from: =COUNTIF($CF$684608:$CF$734608,CU684694)
to: =COUNTIF($CF$684608:$CF$734608,CU684693)
at: BW684608
from: =SUM(COUNTIF($BZ$684608:$CE$784608,CV684694:DA684694))
to: =SUM(COUNTIF($BZ$684608:$CE$784608,CV684693:DA684693))
and last one:
at: BX684608
from: =SUM(COUNTIF($CG$684608:$CL$734608,CV684694:DA684694))
to: =SUM(COUNTIF($CG$684608:$CL$734608,CV684693:DA684693))
it would be great helped if someone can also explain this bit here:
VBA Code:
Formula2 = Left(Bits(0), 2) & Mid(Bits(0), 3) - 1 & ":" & Bits(1)
also, can it be all in one macro?
Last edited by a moderator: