Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert macro that runs against entire column to run in current row
I'm using the following code to run through a column (F) combining
contents of two other columns and change font characteristics of the first couple of characters. I have since created a form that allows the user to enter information. When I click OK on my user form that enters all of the info, I would like to call a macro that performs the same thing but only on the row just added. Seems simple enough but I can't seem to get my head around it. Any help is greatly appreciated. Columns("F:F").Select With Selection.Font ..Name = "Times New Roman" ..FontStyle = "Regular" ..Size = 11 End With With ActiveSheet r = ActiveSheet.Cells(.Rows.Count, 2).End(xlUp).Row End With For i = 2 To r If IsEmpty(Cells(i, 4)) = True Then Cells(i, 6).Value = Cells(i, 5).Value With Cells(i, 6).Characters(Start:=1, Length:=3).Font ..FontStyle = "Bold" End With Else Cells(i, 6).Value = Cells(i, 4).Value & ": " & Cells(i, 5).Value With Cells(i, 6).Characters(Start:=1, Length:=2).Font ..FontStyle = "Bold" End With With Cells(i, 6).Characters(Start:=1, Length:=3).Font ..Size = 8 End With End If Next Range("F1").Select Selection.Font.Bold = True End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert macro that runs against entire column to run in current ro
*untested code*
Sub ddd() Dim r As Long Dim i As Long With Columns("F:F").Font .Name = "Times New Roman" .FontStyle = "Regular" .Size = 11 End With r = Cells(Rows.Count, 2).End(xlUp).Row With Cells(r, 6) If IsEmpty(Cells(r, 4)) = True Then .Value = Cells(r, 5).Value .Characters(Start:=1, Length:=3).Font.FontStyle = "Bold" Else .Value = Cells(r, 4).Value & ": " & Cells(r, 5).Value .Characters(Start:=1, Length:=2).Font.FontStyle = "Bold" .Characters(Start:=1, Length:=3).Font.Size = 8 End If End With Range("F1").Font.Bold = True End Sub -- Wigi http://www.wimgielis.be = Excel/VBA, soccer and music " wrote: I'm using the following code to run through a column (F) combining contents of two other columns and change font characteristics of the first couple of characters. I have since created a form that allows the user to enter information. When I click OK on my user form that enters all of the info, I would like to call a macro that performs the same thing but only on the row just added. Seems simple enough but I can't seem to get my head around it. Any help is greatly appreciated. Columns("F:F").Select With Selection.Font ..Name = "Times New Roman" ..FontStyle = "Regular" ..Size = 11 End With With ActiveSheet r = ActiveSheet.Cells(.Rows.Count, 2).End(xlUp).Row End With For i = 2 To r If IsEmpty(Cells(i, 4)) = True Then Cells(i, 6).Value = Cells(i, 5).Value With Cells(i, 6).Characters(Start:=1, Length:=3).Font ..FontStyle = "Bold" End With Else Cells(i, 6).Value = Cells(i, 4).Value & ": " & Cells(i, 5).Value With Cells(i, 6).Characters(Start:=1, Length:=2).Font ..FontStyle = "Bold" End With With Cells(i, 6).Characters(Start:=1, Length:=3).Font ..Size = 8 End With End If Next Range("F1").Select Selection.Font.Bold = True End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert macro that runs against entire column to run in currentro
On Aug 12, 6:13*pm, Wigi wrote:
*untested code* Sub ddd() Dim r As Long Dim i As Long With Columns("F:F").Font * * .Name = "Times New Roman" * * .FontStyle = "Regular" * * .Size = 11 End With r = Cells(Rows.Count, 2).End(xlUp).Row With Cells(r, 6) * * If IsEmpty(Cells(r, 4)) = True Then * * * * .Value = Cells(r, 5).Value * * * * .Characters(Start:=1, Length:=3).Font.FontStyle = "Bold" * * Else * * * * .Value = Cells(r, 4).Value & ": " & Cells(r, 5).Value * * * * .Characters(Start:=1, Length:=2).Font.FontStyle = "Bold" * * * * .Characters(Start:=1, Length:=3).Font.Size = 8 * * End If End With Range("F1").Font.Bold = True End Sub -- Wigihttp://www.wimgielis.be= Excel/VBA, soccer and music " wrote: I'm using the following code to run through a column (F) combining contents of two other columns and change font characteristics of the first couple of characters. *I have since created a form that allows the user to enter information. *When I click OK on my user form that enters all of the info, I would like to call a macro that performs the same thing but only on the row just added. *Seems simple enough but I can't seem to get my head around it. *Any help is greatly appreciated.. Columns("F:F").Select With Selection.Font ..Name = "Times New Roman" ..FontStyle = "Regular" ..Size = 11 End With With ActiveSheet r = ActiveSheet.Cells(.Rows.Count, 2).End(xlUp).Row End With For i = 2 To r If IsEmpty(Cells(i, 4)) = True Then Cells(i, 6).Value = Cells(i, 5).Value With Cells(i, 6).Characters(Start:=1, Length:=3).Font ..FontStyle = "Bold" End With Else Cells(i, 6).Value = Cells(i, 4).Value & ": " & Cells(i, 5).Value With Cells(i, 6).Characters(Start:=1, Length:=2).Font ..FontStyle = "Bold" End With With Cells(i, 6).Characters(Start:=1, Length:=3).Font ..Size = 8 End With End If Next Range("F1").Select Selection.Font.Bold = True End Sub- Hide quoted text - - Show quoted text - perfectamundo. I knew it would be easy. Many thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs | Setting up and Configuration of Excel | |||
convert to upper case - entire column ? | Excel Discussion (Misc queries) | |||
How to stop other macros while current macro runs | Excel Programming | |||
How do convert an entire column of text in Excel to all caps? | Excel Discussion (Misc queries) | |||
How do you convert an entire column into absolute value? | Excel Worksheet Functions |