LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default VBA ColorIndex Formatting

I'm new to VBA and a first time user to this group. I am having a
problem formatting a created workbook. My code accesses 1 workbook to
pull selected information into a new workbook with multiple worksheets.
Some of the data that is pulled into the workbook has cells with text
in them and colorindex =1 (black). I need to remove the text in the
cell and remove the colorindex.

I have written code that successfully does this for the 1st worksheet
but it will not work on more than one worksheet. I each worksheet as a
private sub that is then called. Below is the code from one worksheet.


Any help with what is wrong in my code would be appreciated.

Thanks!
Robin

Private Sub DiscountsSurcharges()
Dim strStart As String
Dim strStartingCell As String
Dim strEnd As String
Dim strEndingCell As String
Dim intStartRowOffset As Integer
Dim intEndRowOffset As Integer
Dim strColumn As String

wbCRD.Worksheets("Discounts & Surcharges").Activate
Range("B1").Activate

If strChannel = "Agency" Then
strStart = "UPP (10)"
intStartRowOffset = 0
strEnd = "Discounts and Surcharges print on the declarations
page as follows:"
intEndRowOffset = -2
strColumn = "AE"
Else
strStart = "Discounts And Surcharges By Underwriting Tier"
intStartRowOffset = 2
strEnd = "Group D Discount - Does Not Vary by Tier"
intEndRowOffset = 15
strColumn = "Z"
End If

strStartingCell = FindAddress(strStart, intStartRowOffset)
'Replacing the column name in the address
strEndingCell = Replace(FindAddress(strEnd, intEndRowOffset), "B",
strColumn)

Range(strStartingCell, strEndingCell).Select
Selection.Copy
wbThisWorkbook.Activate
Worksheets("Discounts & Surcharges").Activate
Worksheets("Discounts & Surcharges").Range("A8").Select

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Range("A1").Select
Columns("A:A").ColumnWidth = 4.14
Columns("V:V").ColumnWidth = 9.86
Range("A1").Activate

Application.FindFormat.Interior.ColorIndex = 1
Application.ReplaceFormat.Interior.ColorIndex = xlNone
Cells.Replace What:="", Replacement:=" ", LookAt:=xlPart,
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=True,
ReplaceFormat:=True
With Application.FindFormat.Font
.Strikethrough = True
.Subscript = False
End With
Application.FindFormat.Interior.ColorIndex = xlNone
With Application.ReplaceFormat.Font
.Strikethrough = False
.Subscript = False
End With
Cells.Replace What:="", Replacement:=" ", LookAt:=xlPart,
SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=True,
ReplaceFormat:=True
Cells.Select
Selection.Interior.ColorIndex = xlNone
End Sub

 
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
Conditional Formatting Error ddate Excel Worksheet Functions 0 May 5th 05 09:00 PM
difficulty with conditional formatting Deb Excel Discussion (Misc queries) 0 March 23rd 05 06:13 PM
conditional formatting question Deb Excel Discussion (Misc queries) 0 March 23rd 05 02:07 AM
Formatting dates in the future Compass Rose Excel Worksheet Functions 3 January 17th 05 10:39 PM
Conditional formatting not available in Excel BAB Excel Discussion (Misc queries) 2 January 1st 05 03:33 PM


All times are GMT +1. The time now is 01:19 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"