Checkbox Perform IfError Index Function

jap7675

New Member
Joined
Nov 13, 2015
Messages
23
Hello Everyone,

I've been struggling with this for a while now, so i realllyyyy hope someone can help!

I have this code

Private Sub CheckBox1_Click()
If OptionButton1.Value = True Then
Sheets("Sheet1").Select
Range("J4").Select
Selection.FormulaArray = "=IFERROR(INDEX(C$2:C$14, SMALL(IF($B$2:$B$14=1, ROW($B$2:$B$14)-1),ROWS(G$2:G2))),"")"
Selection.Columns.AutoFit

ElseIf OptionButton1.Value = False Then
Range("J4").Value = " "
End If

End Sub

Where I'm trying to get the formula perforned in cell J4. It just wont do it!
And I dont really get why!

Please Help
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
In general, you don't need to select cells to do things with them in VBA. The macro will run faster if you don't have to select cells.

The paste formula method should work for you. Try this:

Code:
[COLOR=#333333]Private Sub CheckBox1_Click()[/COLOR]
'http://www.mrexcel.com/forum/excel-questions/903173-checkbox-perform-iferror-index-function.html
If OptionButton1.Value = True Then
    Worksheets("Sheet1").Range("J4").Formula = "=IFERROR(INDEX(C$2:C$14, SMALL(IF($B$2:$B$14=1, ROW($B$2:$B$14)-1),ROWS(G$2:G2))),"""")"
Else
    Range("J4").Value = ""
End If
End Sub
 
Upvote 0
Hi, Thanks so much for your hel - im getting really close to solving my problem.



Private Sub CheckBox1_Click()

If CheckBox1.Value = True Then
Sheets("Sheet1").Range("J4:J40").FormulaArray = "=IFERROR(INDEX(C$2:C$14, SMALL(IF($B$2:$B$14=1, ROW($B$2:$B$14)-1),ROWS(G$2:G2))),"""")"
Sheets("Sheet1").Range("J4:J40").Columns().AutoFit

ElseIf CheckBox1.Value = False Then
Range("J4:J40").Value = " "
End If

End Sub



I just need the (G$2:G2) to occur sequentially {e.g. ((G$2:G3), (G$2:G4)), (G$2:G5)) etc}when the formula is repeated across the rane. Is this possible?
 
Upvote 0

Forum statistics

Threads
1,222,752
Messages
6,168,007
Members
452,160
Latest member
Bekerinik

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