Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Test for value then format!

Thanks to Don Guillett I found the below code and it works great. But I need
it to select more than one cell to format. Is it possible to modify the code
to select several cells in the same row?

Sub insertline()
For Each c In Range("a2:a100")
If UCase(c) = "TOTAL" Then
With c.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End If
Next c
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Test for value then format!

For example!

Your code does exactly what I want except... I would like to select more
than one cell in the same row. For example;

The search finds the value "total" in A2.
I then want it to select from A2:A10 and format the entire selection. Is
that possible or is this an entirelly different beast?

"Don Guillett" wrote:

Example layout and cells desired


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"AirgasRob" wrote in message
...
Thanks to Don Guillett I found the below code and it works great. But I
need
it to select more than one cell to format. Is it possible to modify the
code
to select several cells in the same row?

Sub insertline()
For Each c In Range("a2:a100")
If UCase(c) = "TOTAL" Then
With c.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End If
Next c
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Test for value then format!

i'll chime in here and modify don's code, since you said it's what you want

Sub insertline()
For Each c In Range("a2:a100")
If UCase(c) = "TOTAL" Then

With c.Resize(9).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End If
Next c
End Sub

--


Gary

"AirgasRob" wrote in message
...
For example!

Your code does exactly what I want except... I would like to select more
than one cell in the same row. For example;

The search finds the value "total" in A2.
I then want it to select from A2:A10 and format the entire selection. Is
that possible or is this an entirelly different beast?

"Don Guillett" wrote:

Example layout and cells desired


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"AirgasRob" wrote in message
...
Thanks to Don Guillett I found the below code and it works great. But I
need
it to select more than one cell to format. Is it possible to modify the
code
to select several cells in the same row?

Sub insertline()
For Each c In Range("a2:a100")
If UCase(c) = "TOTAL" Then
With c.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End If
Next c
End Sub





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Test for value then format!

Don's code examines the contents of each cell in the range from A2 thru A100
and formats according to contents. Change:

For Each c In Range("a2:a100")
to:
For Each c In Selection

Then you first select any group of cells and then run the macro.
--
Gary''s Student - gsnu200806


"AirgasRob" wrote:

Thanks to Don Guillett I found the below code and it works great. But I need
it to select more than one cell to format. Is it possible to modify the code
to select several cells in the same row?

Sub insertline()
For Each c In Range("a2:a100")
If UCase(c) = "TOTAL" Then
With c.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End If
Next c
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Test for value then format!

Thank you, I didn't know I could do that. I have some other worksheets where
this will come in very handy.

"Gary''s Student" wrote:

Don's code examines the contents of each cell in the range from A2 thru A100
and formats according to contents. Change:

For Each c In Range("a2:a100")
to:
For Each c In Selection

Then you first select any group of cells and then run the macro.
--
Gary''s Student - gsnu200806


"AirgasRob" wrote:

Thanks to Don Guillett I found the below code and it works great. But I need
it to select more than one cell to format. Is it possible to modify the code
to select several cells in the same row?

Sub insertline()
For Each c In Range("a2:a100")
If UCase(c) = "TOTAL" Then
With c.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End If
Next c
End Sub

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Test on the format of a cell in a formula ? brunzeg New Users to Excel 1 November 13th 09 11:05 AM
How can I test for colour format in if statements? Colin Excel Worksheet Functions 1 April 6th 09 10:56 AM
Can one test for Excel cell format patterns? genie56 Excel Programming 2 May 18th 07 04:12 AM
Is there a logical test for a cell's format instead of contents Bruce Excel Worksheet Functions 3 November 17th 05 01:40 AM
Test a file to retrieve format Ago Excel Programming 1 December 17th 03 02:53 PM


All times are GMT +1. The time now is 11:13 AM.

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"