LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Need help adding If/Then/Else Statement

If I knew how to write macros, I would tell the macro I have below to
run
IF Len(B1) 1 ...
ELSE [if Len(B1)<1 IsNull or whatever is correct] paste C1 pasted into
D; apply bold to the first three characters and do not change the font
size.

B C D
RCCode PartyFix Party
AB Smith AB: Smith
Jones Jones


Sub RCCodeFixFont()
Dim CalcMode As Long
Dim sLF As String
Dim R As Long
Dim cell As Range
Dim p As Long


sLF = Chr$(58) & Chr$(160)
With Application
.ScreenUpdating = False
CalcMode = .Calculation
.Calculation = xlCalculationManual
End With

With ActiveSheet
R = .Cells(.Rows.Count, 1).End(xlUp).Row


With .Range("D1").Resize(R, 1)
'comment out the next 4 lines if you've already
'got the text into the cells


.Formula = "=B1&CHAR(58)&CHAR(160)&C1"
.Calculate
.Copy
.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False


'apply common formats to entire column at once
With .Font
.Name = "Times New Roman"
.Size = 11
.FontStyle = "Regular"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With


.WrapText = True


For Each cell In .Cells
With cell
p = InStr(.Value, sLF)
If p 1 Then
With .Characters(Start:=1, Length:=p - 1).Font
.FontStyle = "Bold"
.Size = 8
End With
End If
End With 'cell
Next cell
End With 'entire range
End With 'active sheet


With Application
.Calculation = CalcMode
.ScreenUpdating = True
End With


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
Adding a WHERE statement NEWER USER Excel Programming 2 January 25th 08 06:38 PM
Adding A Not(IsBlank) To IF Statement(help) getmhawks Excel Worksheet Functions 2 June 12th 06 10:43 PM
adding if statement results Robb27 Excel Worksheet Functions 3 November 20th 04 05:27 AM
Adding a 3rd IF statement ?? yh73090[_5_] Excel Programming 3 October 17th 04 05:57 PM
Adding a 3rd IF statement ?? yh73090[_6_] Excel Programming 0 October 17th 04 04:50 AM


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