Code doesnt appear in cell as it should

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,224
Office Version
  1. 2007
Platform
  1. Windows
Hi,
Please could you take a look at my code and advise what i have done wrong.

I select an option button on a userform & transfer oit to my worksheet, This works fine.

What i need to do it format then the value in the cell I9 Bold Calibri etc etc but this is the part that has no affect.

Rich (BB code):
Private Sub CommandButton1_Click()
    
 With ThisWorkbook.Worksheets("RANGER")
    If OptionButton3.Value = True Then .Cells(lastrow + 5, 9).Value = "N 41601-501-41": OptionButton3.Value = False
    If OptionButton4.Value = True Then .Cells(lastrow + 5, 9).Value = "N 41803-501-42": OptionButton4.Value = False
    If OptionButton5.Value = True Then .Cells(lastrow + 5, 9).Value = "V 41803-501-43": OptionButton5.Value = False
 End With
 
    Range("I9").Font.Size = 14
    Range("I9").Font.Name = "Calibri"
    Range("I9").Font.Bold = True
    Range("I9").HorizontalAlignment = xlCenter
    Range("I9").VerticalAlignment = xlVAlignCenter
    Unload RangerPcbNumber
    
End Sub
 

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
It is formatting I9 on the ActiveSheet because you haven't referenced/specified the sheet for it to act on.
 
Upvote 0
Range I9 is unqualified - try following update to your code


VBA Code:
Private Sub CommandButton1_Click()
    
 With ThisWorkbook.Worksheets("RANGER")
    If OptionButton3.Value = True Then .Cells(lastrow + 5, 9).Value = "N 41601-501-41": OptionButton3.Value = False
    If OptionButton4.Value = True Then .Cells(lastrow + 5, 9).Value = "N 41803-501-42": OptionButton4.Value = False
    If OptionButton5.Value = True Then .Cells(lastrow + 5, 9).Value = "V 41803-501-43": OptionButton5.Value = False
 
 
    With .Range("I9")
        .Font.Size = 14
        .Font.Name = "Calibri"
        .Font.Bold = True
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlVAlignCenter
    End With
    
End With
    Unload RangerPcbNumber
    
End Sub

Dave
 
Upvote 0
Solution
Thanks i now see my mistake.

Also I9 should of been I5

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,980
Members
448,934
Latest member
audette89

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