Update Multiple Cells if Combo Box Value = "Y"

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
701
Office Version
  1. 365
Platform
  1. Windows
I'm trying to update a range of sequential cells to "Y" if the value of a combo box = "Y". I'm getting a method of range object error at the line in red font. The Else portion of the code works fine. Will I need to line out each individual range?

VBA Code:
If Me.cobo_All.Value = "Y" Then
    mI.Range("E:O" & mINR).Value = Me.cobo_All.Value
Else
    mI.Range("E" & mINR).Value = Me.cobo_AHPYN.Value
    mI.Range("F" & mINR).Value = Me.cobo_ANHPYN.Value
    mI.Range("G" & mINR).Value = Me.cobo_BTYN.Value
    mI.Range("H" & mINR).Value = Me.cobo_CLYN.Value
    mI.Range("I" & mINR).Value = Me.cobo_DAPYN.Value
    mI.Range("J" & mINR).Value = Me.cobo_DisYN.Value
    mI.Range("K" & mINR).Value = Me.cobo_FLYN.Value
    mI.Range("L" & mINR).Value = Me.cobo_HPYN.Value
    mI.Range("M" & mINR).Value = Me.cobo_PPYN.Value
    mI.Range("N" & mINR).Value = Me.cobo_RPYN.Value
    mI.Range("O" & mINR).Value = Me.cobo_TPYN.Value
End If
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Note that you CANNOT use formatting options inside of Excel or VBA code tags. It only works inside Rich code tags.

This is NOT a valid range reference:
VBA Code:
Range("E:O" & mINR)
if you want to add in a row number, it must be added to BOTH column references, i.e.
VBA Code:
Range("E" & mINR & ":O" & mINR)
 
Upvote 0
Solution
Note that you CANNOT use formatting options inside of Excel or VBA code tags. It only works inside Rich code tags.

This is NOT a valid range reference:
VBA Code:
Range("E:O" & mINR)
if you want to add in a row number, it must be added to BOTH column references, i.e.
VBA Code:
Range("E" & mINR & ":O" & mINR)
Thanks @Joe4
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,664
Members
449,114
Latest member
aides

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