am i missing something in code?

bhandari

Active Member
Joined
Oct 17, 2017
Messages
359
Code:
Sub ThirdClass()
Dim Finalrow As Long
i As Double
Finalrow = cells(65536, 1).End(xlUp).Row
For i = 1 To Finalrow
cells(1, 1).Resize(, 5).Font.Bold = True
Next i
End Sub
error=statement invalid outside type block
i want 5th column text=bold
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
That declaration requires Dim, just like the line above.
 
Upvote 0
i want 5th column text=bold
and if it is just the 5th column....

Code:
Sub ThirdClass()
Dim Finalrow As Long
Finalrow = Cells(Rows.Count, 1).End(xlUp).Row

Range(Cells(1, 5), Cells(Finalrow, 5)).Font.Bold = True

End Sub

What you have in the code you posted is the first 5 columns.
 
Last edited:
Upvote 0
i cant see bold for 5th column

as well as i have similar code
There is a argumrnt error can u please find out
Code:
Sub ThirdClassMethod1()
'need to check it's not working
Dim Finalrow As Long
Dim i As Double
Finalrow = cells(65536, 1).End(xlUp).Row
For i = 1 To Finalrow
cells("A" & i & ":E" & i).Bold = True
Next i
End Sub
 
Upvote 0
See post number 3

If you want it for the first 5 columns

Rich (BB code):
Sub ThirdClass()
Dim Finalrow As Long
Finalrow = Cells(Rows.Count, 1).End(xlUp).Row

Range(Cells(1, 1), Cells(Finalrow, 5)).Font.Bold = True

End Sub
 
Last edited:
Upvote 0
Thank you for your Valuable suggistion
cant we try with this code
How it will work?
Code:
For i = 1 To Finalrow
cells("A" & i & ":E" & i).Bold = True
Code:
For i = 1 To Finalrow
cells(1, 1).Resize(, 5).Font.Bold = True
 
Upvote 0
i want 5th column text=bold

Bhandari,

If I understand you correctly, then see if the following changes will work for you:

Code:
Sub ThirdClass_V2()
' hiker95, 10/28/2017, ME1029086
Dim Finalrow As Long
Dim i As Long
Finalrow = Cells(65536, 1).End(xlUp).Row
For i = 1 To Finalrow
  Cells(i, 5).Font.Bold = True
Next i
End Sub
 
Last edited:
Upvote 0
Thank you for your Valuable suggistion
cant we try with this code
How it will work?
Code:
For i = 1 To Finalrow
cells("A" & i & ":E" & i).Bold = True
Code:
For i = 1 To Finalrow
cells(1, 1).Resize(, 5).Font.Bold = True

Why would you want to loop through the cells which is slower than referring directly to the range?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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