Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
BeSmart
 
Posts: n/a
Default Find cells without multiple spacebars and format...

Hi all (warning novice approaching)....

I'm writing VBE code and I want to find cells in column A where the text
entered does not start with 5 spacebars eg:

Alligators aren't always aggressive...
Blue bulls blow big...

Great grapes grow ....
Pink pigs put purple....

In the above example I need the code to pick up the "The quick brown
Fox...." row and the "Great grapes grow..." row and make them bold. The
"Blue Bulls" row and the "Pink pigs" row stay unbold.

I've tried the following code but it makes all active cells bold..
What am I doing wrong? Any help would be greatly appreciated.

.......

Dim i
For i = 1 To Cells(Rows.Count, "a").End(xlUp).Row
If Cells(i, "a").Value < " *" Then
Cells(i, "a").Font.FontStyle = "Bold"
End If
Next


--
Thank for your help
BeSmart
  #2   Report Post  
R.VENKATARAMAN
 
Posts: n/a
Default

suppose your data is in cells G4 to G8 then try this url
(if it is some other range then make change in the line starting from "for
each cell in .........."
in the lline starting with "if" the space between quotes must be five blank
spaces

Public Sub test()
Dim cell As Range
For Each cell In Range("g4:g8")
cell.Activate
If Left(ActiveCell, 5) < " " Then
ActiveCell.Font.Bold = True
End If
Next

End Sub





BeSmart wrote in message
...
Hi all (warning novice approaching)....

I'm writing VBE code and I want to find cells in column A where the text
entered does not start with 5 spacebars eg:

Alligators aren't always aggressive...
Blue bulls blow big...

Great grapes grow ....
Pink pigs put purple....

In the above example I need the code to pick up the "The quick brown
Fox...." row and the "Great grapes grow..." row and make them bold. The
"Blue Bulls" row and the "Pink pigs" row stay unbold.

I've tried the following code but it makes all active cells bold..
What am I doing wrong? Any help would be greatly appreciated.

......

Dim i
For i = 1 To Cells(Rows.Count, "a").End(xlUp).Row
If Cells(i, "a").Value < " *" Then
Cells(i, "a").Font.FontStyle = "Bold"
End If
Next


--
Thank for your help
BeSmart



  #3   Report Post  
Dave Peterson
 
Posts: n/a
Default

You may want to dump the code and use Format|conditional formatting.

With a formula like:

=LEFT(A1,5)<REPT(" ",5)



BeSmart wrote:

Hi all (warning novice approaching)....

I'm writing VBE code and I want to find cells in column A where the text
entered does not start with 5 spacebars eg:

Alligators aren't always aggressive...
Blue bulls blow big...

Great grapes grow ....
Pink pigs put purple....

In the above example I need the code to pick up the "The quick brown
Fox...." row and the "Great grapes grow..." row and make them bold. The
"Blue Bulls" row and the "Pink pigs" row stay unbold.

I've tried the following code but it makes all active cells bold..
What am I doing wrong? Any help would be greatly appreciated.

......

Dim i
For i = 1 To Cells(Rows.Count, "a").End(xlUp).Row
If Cells(i, "a").Value < " *" Then
Cells(i, "a").Font.FontStyle = "Bold"
End If
Next

--
Thank for your help
BeSmart


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"