Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I was wondering if there is a way to compare text formatting in excel
VBA. Basically I am creating a summary page in excel from an export from another program. However, the exported document is poorly formated, so I want to move cells around and whatnot based on the format of a cell. For an example if a cell has the same formatting as a specific cell, then I want to move it (the specific cell is bold, italic, arial size 10). How would you do this using VBA? I tried using something along the lines of: If ActiveSheet.Range("E" & i).NumberFormat = ActiveSheet.Range_("E8").NumberFormat..... Then do some reformating But I dont think that will work because the formatting is general for both cells. Any help would be greatly appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
something along these lines: Public Function SameFormat(s As Range, t As Range) As Boolean ' s = source range ' t = target range, the reference cell's range SameFormat = True If s.Font.Italic < t.Font.Italic Then SameFormat = False Exit Function End If If s.Font.name < t.Font.name Then SameFormat = False Exit Function End If If s.Font.Size < t.Font.Size Then SameFormat = False Exit Function End If If s.Font.Bold < t.Font.Bold Then SameFormat = False Exit Function End If ' more if you like End Function ' --------------------- Sub Test5555() MsgBox SameFormat(Cells(1, 1), Cells(1, 2)) End Sub -- Helmut Weber Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de" |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Apr 28, 1:22 pm, Helmut Weber wrote:
Hi, something along these lines: Public Function SameFormat(s As Range, t As Range) As Boolean ' s = source range ' t = target range, the reference cell's range SameFormat = True If s.Font.Italic < t.Font.Italic Then SameFormat = False Exit Function End If If s.Font.name < t.Font.name Then SameFormat = False Exit Function End If If s.Font.Size < t.Font.Size Then SameFormat = False Exit Function End If If s.Font.Bold < t.Font.Bold Then SameFormat = False Exit Function End If ' more if you like End Function ' --------------------- Sub Test5555() MsgBox SameFormat(Cells(1, 1), Cells(1, 2)) End Sub -- Helmut Weber Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de" I will try that thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Compare text in cell to custom text format?? | Excel Discussion (Misc queries) | |||
Compare cells including formatting | Excel Programming | |||
Compare two Sheets with Conditional Formatting | Excel Discussion (Misc queries) | |||
Compare two Sheets with Conditional Formatting | Excel Discussion (Misc queries) | |||
conditional formatting - compare 2 dates | Excel Discussion (Misc queries) |