PDA

View Full Version : Solved: Mergin two bits of code to format cell



PEV
02-20-2012, 09:23 AM
I am trying to format with color the output from a Userform onto the spreadsheet. The below code (or part of) is attached to a Button on the Userform. How can merge the two parts? Part 1 being the value in ComboBox 86 being sent to the sheet and Part 2 being the formatting. For now, it is formating any active cells chosen only and not the destination cell (offset (1,0)) for example. I was using Conditional Formatting in Excel 2010 but many of the users are still on 2003 which limits to 3 conditional formats


Dim LastRow As Object
Set LastRow = Sheets("tt").Range("B65536, M65536").End(xlUp)
'Header & origin destination

Application.ScreenUpdating = False

LastRow.Offset(1, 0).Value = ComboBox86.Text
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.Font.Bold = True
LastRow.Offset(1, 1).Value = ("")
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With

Bob Phillips
02-20-2012, 09:26 AM
Sub ApplyTurnroundFormat()
Dim LastCell As range

Set LastCell = Sheets("tt").Range("B65536, M65536").End(xlUp)
'Header & origin destination

Application.ScreenUpdating = False

With LastCell

With .Offset(1, 0)

.Value = ComboBox86.Text

With .Interior

.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With

.Font.Bold = True
End With

With .Offset(1, 1)

.Value = ("")

With .Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End With
End With
End Sub

PEV
02-20-2012, 09:33 AM
Geez, that was quick. I have about a 100 boxes in my userform so I better get at it ;)

thanks will will close once i'm done