Fill formula in the alternate rows and live values

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Fill formula in the alternate rows and live values

Hello,

I am looking VBA solution, which can fill formula in the alternate row and live only values

For example this formula =COUNTIF(Sheet1!$F$6:$F$63,$C6&" | "&$D6&" | "&F$4)
I want to fill in the range F6:T28 but using alternate rows what I mean fill row 6 in cells F6:T6 than leave the row 7 and fill in cells F8:T8 and so on in all the cells are shown with 0

Sample Data


Book1
ABCDEFGHIJKLMNOPQRSTU
1
2
3
4Data C->01234567891011121314
5Data AData B
601000000000000000
7
8125000000000000000
9
1029000000000000000
11
121212000000000000000
13
14131000000000000000
15
1651000000000000000
17
1865000000000000000
19
2079000000000000000
21
22825000000000000000
23
24974000000000000000
25
261018000000000000000
27
281012000000000000000
29
30
31
Sheet3
Cell Formulas
RangeFormula
F6=COUNTIF(Sheet1!$F$6:$F$63,$C6&" | "&$D6&" | "&F$4)


Thank you all
Excel 2000
Regards,
Moti
 
Last edited:

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Code:
[color=darkblue]Sub[/color] Fill_Formula()
    [color=darkblue]With[/color] Intersect(Range("C:C").SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow, Columns("F:T"))
        .Formula = "=COUNTIF(Sheet1!$F$6:$F$63,$C6&"" | ""&$D6&"" | ""&F$4)"
        .Value = .Value
    [color=darkblue]End[/color] [color=darkblue]With[/color]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0
Code:
[COLOR=darkblue]Sub[/COLOR] Fill_Formula()
    [COLOR=darkblue]With[/COLOR] Intersect(Range("C:C").SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow, Columns("F:T"))
        .Formula = "=COUNTIF(Sheet1!$F$6:$F$63,$C6&"" | ""&$D6&"" | ""&F$4)"
        .Value = .Value
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
Hello AlphaFrog,

Thank you for giving VBA solution, after I run the VBA getting only values 0

I tried using key F8 find at the line (.Formula = "=COUNTIF(Sheet1!$F$6:$F$63,$C6&"" | ""&$D6&"" | ""&F$4)" ) it fills formula in the alternate range and gives count where the value matches.
but as I hit F8 to line (.Value = .Value) all even count results converted in 0, I don't know what I am doing wrong

Please could you check?

Regards,
Moti
 
Last edited:
Upvote 0
Hello, here is sheet1 & and I want after the formulas fills, Results in sheet3 as shown below may this help

Data Sheet....

Book1
EFG
1
2
3
4
5Data
60 | 1 | 1
712 | 5 | 5
82 | 9 | 7
912 | 12 | 13
1013 | 1 | 12
115 | 1 | 4
126 | 5 | 8
137 | 9 | 5
148 | 25 | 3
159 | 74 | 0
1610 | 18 | 8
1710 | 12 | 13
180 | 1 | 7
1912 | 5 | 2
202 | 9 | 1
2112 | 12 | 11
2213 | 1 | 9
235 | 1 | 9
246 | 5 | 6
257 | 9 | 6
268 | 25 | 3
279 | 74 | 2
2810 | 18 | 1
2910 | 12 | 7
30
31
Sheet1


Result Expected

Book1
ABCDEFGHIJKLMNOPQRSTU
1
2
3
4Data C->01234567891011121314
5Data AData B
601010000010000000
7
8125001001000000000
9
1029010000010000000
11
121212000000000001010
13
14131000000000100100
15
1651000010000100000
17
1865000000101000000
19
2079000001100000000
21
22825000200000000000
23
24974101000000000000
25
261018010000001000000
27
281012000000010000010
29
30
31
Sheet3


Regards,
Moti
 
Upvote 0
Try this...

Code:
[COLOR=darkblue]Sub[/COLOR] Fill_Formula()
    [COLOR=darkblue]Dim[/COLOR] rngArea As Range
    [COLOR=darkblue]With[/COLOR] Intersect(Range("C:C").SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow, Columns("F:T"))
        .Formula = "=COUNTIF(Sheet1!$F$6:$F$63,$C6&"" | ""&$D6&"" | ""&F$4)"
        [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] rngArea [COLOR=darkblue]In[/COLOR] .Areas
            rngArea.Value = rngArea.Value
        [COLOR=darkblue]Next[/COLOR]
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
 
Last edited:
Upvote 0
Try this...

Code:
[COLOR=darkblue]Sub[/COLOR] Fill_Formula()
    [COLOR=darkblue]Dim[/COLOR] rngArea As Range
    [COLOR=darkblue]With[/COLOR] Intersect(Range("C:C").SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow, Columns("F:T"))
        .Formula = "=COUNTIF(Sheet1!$F$6:$F$63,$C6&"" | ""&$D6&"" | ""&F$4)"
        [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] rngArea [COLOR=darkblue]In[/COLOR] .Areas
            rngArea.Value = rngArea.Value
        [COLOR=darkblue]Next[/COLOR]
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
AlphaFrog, spot on it is resulting perfect!

Thank you so much for your kind help

Have a nice weekend

Regards,
Moti
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top