Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Macro Removes Cell Borders

Excel 2003

This is a pretty trivial issue, but it's one of those things that is just
driving me nuts. I have the following very simple macros:

**********
Dim ActionCell As String
Dim ColorCodeCell As String
Dim ColorNumber As Integer

Private Sub BuildRangeVariables()

Dim RowNumber As Integer

RowNumber = ActiveCell.Row
ActionCell = "I" & RowNumber
ColorCodeCell = "H" & RowNumber

End Sub

Private Sub MarkRow()

BuildRangeVariables
Rows(ActiveCell.Row).Select
With Selection.Interior
.ColorIndex = ColorNumber
.Pattern = xlSolid
End With

End Sub

Sub MarkClear()

ColorNumber = 0
MarkRow
Range(ColorCodeCell).Select
ActiveCell.Clear
Range(ActionCell).Select
ActiveCell.Clear

End Sub
**********

Basically, I have a spreadsheet with a few thousand rows, and I use a series
of simple macros to mark each row by using a fill color and adding a text
values to columns H and I. The macros that add the text values are not
shown here, but the value in column H is the name of a color (so that I can
use the filter to see all the rows marked with the given color) and the
values in column I can be "Remove," "Test," or "Update" (again, so I can
filter on those values). When I have completed the action for the given row
I run the MarkClear macro, which simply removes the fill color and clears
the values in columns H and I.

While I have omitted some macros, the routines shown above are the COMPLETE
logic flow for the MarkClear routine.

It all works just fine, but for one tiny irritating flaw. When I run the
MarkClear macro it also removes the cell borders. Can anyone tell me why
that happens?

--Tom


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macro Removes Cell Borders


try xlnone instead of 0


Private Sub MarkRow()
Rows(ActiveCell.Row).Interior.ColorIndex = xlnone
End Sub

Sub MarkClear()
MarkRow
Range(ColorCodeCell).Clear
Range(ActionCell).Clear
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Thomas M." wrote in message
...
Excel 2003

This is a pretty trivial issue, but it's one of those things that is just
driving me nuts. I have the following very simple macros:

**********
Dim ActionCell As String
Dim ColorCodeCell As String
Dim ColorNumber As Integer

Private Sub BuildRangeVariables()

Dim RowNumber As Integer

RowNumber = ActiveCell.Row
ActionCell = "I" & RowNumber
ColorCodeCell = "H" & RowNumber

End Sub

Private Sub MarkRow()

BuildRangeVariables
Rows(ActiveCell.Row).Select
With Selection.Interior
.ColorIndex = ColorNumber
.Pattern = xlSolid
End With

End Sub

Sub MarkClear()

ColorNumber = 0
MarkRow
Range(ColorCodeCell).Select
ActiveCell.Clear
Range(ActionCell).Select
ActiveCell.Clear

End Sub
**********

Basically, I have a spreadsheet with a few thousand rows, and I use a
series of simple macros to mark each row by using a fill color and adding
a text values to columns H and I. The macros that add the text values are
not shown here, but the value in column H is the name of a color (so that
I can use the filter to see all the rows marked with the given color) and
the values in column I can be "Remove," "Test," or "Update" (again, so I
can filter on those values). When I have completed the action for the
given row I run the MarkClear macro, which simply removes the fill color
and clears the values in columns H and I.

While I have omitted some macros, the routines shown above are the
COMPLETE logic flow for the MarkClear routine.

It all works just fine, but for one tiny irritating flaw. When I run the
MarkClear macro it also removes the cell borders. Can anyone tell me why
that happens?

--Tom


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro Removes Cell Borders

Clear clears all formatting. Try using ClearContents

Sub MarkClear()

ColorNumber = 0
MarkRow
Range(ColorCodeCell).ClearContents
Range(ActionCell).ClearContents

End Sub

--
Regards,
Tom Ogilvy


"Thomas M." wrote:

Excel 2003

This is a pretty trivial issue, but it's one of those things that is just
driving me nuts. I have the following very simple macros:

**********
Dim ActionCell As String
Dim ColorCodeCell As String
Dim ColorNumber As Integer

Private Sub BuildRangeVariables()

Dim RowNumber As Integer

RowNumber = ActiveCell.Row
ActionCell = "I" & RowNumber
ColorCodeCell = "H" & RowNumber

End Sub

Private Sub MarkRow()

BuildRangeVariables
Rows(ActiveCell.Row).Select
With Selection.Interior
.ColorIndex = ColorNumber
.Pattern = xlSolid
End With

End Sub

Sub MarkClear()

ColorNumber = 0
MarkRow
Range(ColorCodeCell).Select
ActiveCell.Clear
Range(ActionCell).Select
ActiveCell.Clear

End Sub
**********

Basically, I have a spreadsheet with a few thousand rows, and I use a series
of simple macros to mark each row by using a fill color and adding a text
values to columns H and I. The macros that add the text values are not
shown here, but the value in column H is the name of a color (so that I can
use the filter to see all the rows marked with the given color) and the
values in column I can be "Remove," "Test," or "Update" (again, so I can
filter on those values). When I have completed the action for the given row
I run the MarkClear macro, which simply removes the fill color and clears
the values in columns H and I.

While I have omitted some macros, the routines shown above are the COMPLETE
logic flow for the MarkClear routine.

It all works just fine, but for one tiny irritating flaw. When I run the
MarkClear macro it also removes the cell borders. Can anyone tell me why
that happens?

--Tom



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Macro Removes Cell Borders

Thanks for the information. Unfortunately, I was unable to get this
approach to work.

--Tom

"Don Guillett" wrote in message
...

try xlnone instead of 0


Private Sub MarkRow()
Rows(ActiveCell.Row).Interior.ColorIndex = xlnone
End Sub

Sub MarkClear()
MarkRow
Range(ColorCodeCell).Clear
Range(ActionCell).Clear
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Thomas M." wrote in message
...
Excel 2003

This is a pretty trivial issue, but it's one of those things that is just
driving me nuts. I have the following very simple macros:

**********
Dim ActionCell As String
Dim ColorCodeCell As String
Dim ColorNumber As Integer

Private Sub BuildRangeVariables()

Dim RowNumber As Integer

RowNumber = ActiveCell.Row
ActionCell = "I" & RowNumber
ColorCodeCell = "H" & RowNumber

End Sub

Private Sub MarkRow()

BuildRangeVariables
Rows(ActiveCell.Row).Select
With Selection.Interior
.ColorIndex = ColorNumber
.Pattern = xlSolid
End With

End Sub

Sub MarkClear()

ColorNumber = 0
MarkRow
Range(ColorCodeCell).Select
ActiveCell.Clear
Range(ActionCell).Select
ActiveCell.Clear

End Sub
**********

Basically, I have a spreadsheet with a few thousand rows, and I use a
series of simple macros to mark each row by using a fill color and adding
a text values to columns H and I. The macros that add the text values
are not shown here, but the value in column H is the name of a color (so
that I can use the filter to see all the rows marked with the given
color) and the values in column I can be "Remove," "Test," or "Update"
(again, so I can filter on those values). When I have completed the
action for the given row I run the MarkClear macro, which simply removes
the fill color and clears the values in columns H and I.

While I have omitted some macros, the routines shown above are the
COMPLETE logic flow for the MarkClear routine.

It all works just fine, but for one tiny irritating flaw. When I run the
MarkClear macro it also removes the cell borders. Can anyone tell me why
that happens?

--Tom




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Macro Removes Cell Borders

I looked up ClearContents in the Help and it sounds like it should cure my
problem, but in fact I have been unable to get it to work. The issue is not
very important, so at this point I think I'll just live with it.

--Tom

"Tom Ogilvy" wrote in message
...
Clear clears all formatting. Try using ClearContents

Sub MarkClear()

ColorNumber = 0
MarkRow
Range(ColorCodeCell).ClearContents
Range(ActionCell).ClearContents

End Sub

--
Regards,
Tom Ogilvy


"Thomas M." wrote:

Excel 2003

This is a pretty trivial issue, but it's one of those things that is just
driving me nuts. I have the following very simple macros:

**********
Dim ActionCell As String
Dim ColorCodeCell As String
Dim ColorNumber As Integer

Private Sub BuildRangeVariables()

Dim RowNumber As Integer

RowNumber = ActiveCell.Row
ActionCell = "I" & RowNumber
ColorCodeCell = "H" & RowNumber

End Sub

Private Sub MarkRow()

BuildRangeVariables
Rows(ActiveCell.Row).Select
With Selection.Interior
.ColorIndex = ColorNumber
.Pattern = xlSolid
End With

End Sub

Sub MarkClear()

ColorNumber = 0
MarkRow
Range(ColorCodeCell).Select
ActiveCell.Clear
Range(ActionCell).Select
ActiveCell.Clear

End Sub
**********

Basically, I have a spreadsheet with a few thousand rows, and I use a
series
of simple macros to mark each row by using a fill color and adding a text
values to columns H and I. The macros that add the text values are not
shown here, but the value in column H is the name of a color (so that I
can
use the filter to see all the rows marked with the given color) and the
values in column I can be "Remove," "Test," or "Update" (again, so I can
filter on those values). When I have completed the action for the given
row
I run the MarkClear macro, which simply removes the fill color and clears
the values in columns H and I.

While I have omitted some macros, the routines shown above are the
COMPLETE
logic flow for the MarkClear routine.

It all works just fine, but for one tiny irritating flaw. When I run the
MarkClear macro it also removes the cell borders. Can anyone tell me why
that happens?

--Tom





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
Setting borders with a macro orquidea Excel Discussion (Misc queries) 2 January 10th 08 05:21 PM
Replace Function Removes Text Formats In Cell Angst Excel Discussion (Misc queries) 0 March 9th 07 05:28 PM
Macro to change cell borders Roddie Grant Excel Programming 5 February 3rd 05 10:35 AM
A MACRO TO BUILD BORDERS lar48ry Excel Programming 5 January 27th 05 01:53 PM
Using a macro to add borders Colin Foster[_3_] Excel Programming 1 October 19th 04 07:14 PM


All times are GMT +1. The time now is 09:28 PM.

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

About Us

"It's about Microsoft Excel"