Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() What is my error? in the following piece of code? Format_Cells(A) is a function; A is a Range Object. I'm trying to call the function Function Format_Cells(A As Range) in my main code with error 424 --------------------------------------------------------------- Main Program --------------------------------------------------------------- Dim A as Range Range("Y11:BR41").Select Set A = Worksheets("Summary").Range("Y11:BR41") Format_Cells (A) --------------------------------------------------------------- Function --------------------------------------------------------------- Function Format_Cells(A As Range) With Selection.Borders(xlEdgeLeft) ..LineStyle = xlContinuous ..Weight = xlThin ..ColorIndex = 16 End With With Selection.Borders(xlEdgeTop) ..LineStyle = xlContinuous ..Weight = xlThin ..ColorIndex = 16 End With With Selection.Borders(xlEdgeBottom) ..LineStyle = xlContinuous ..Weight = xlThin ..ColorIndex = 2 End With With Selection.Borders(xlEdgeRight) ..LineStyle = xlContinuous ..Weight = xlThin ..ColorIndex = 2 End With With Selection.Borders(xlInsideVertical) ..LineStyle = xlContinuous ..Weight = xlHairline ..ColorIndex = 16 End With With Selection.Borders(xlInsideHorizontal) ..LineStyle = xlContinuous ..Weight = xlHairline ..ColorIndex = 16 End With With Selection.Interior ..ColorIndex = 19 ..Pattern = xlSolid ..PatternColorIndex = xlAutomatic End With With Selection.Font ..Name = "Tahoma" ..FontStyle = "Regular" ..Size = 8 ..ColorIndex = xlAutomatic End With End Function ---------------------------------------------------------------- -- Baapi ------------------------------------------------------------------------ Baapi's Profile: http://www.excelforum.com/member.php...o&userid=27333 View this thread: http://www.excelforum.com/showthread...hreadid=469377 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Your function doesn't return anything, so change it to a sub instead.
Your "with" syntax is wrong - check docs. You pass a range to the code but do not use it in the routine Try something like: Sub FormatCells(rng as range) With rng.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 16 End With 'etc etc End Sub Call like this FormatCells Worksheets("Summary").Range("Y11:BR41") -- Tim Williams Palo Alto, CA "Baapi" wrote in message ... What is my error? in the following piece of code? Format_Cells(A) is a function; A is a Range Object. I'm trying to call the function Function Format_Cells(A As Range) in my main code with error 424 --------------------------------------------------------------- Main Program --------------------------------------------------------------- Dim A as Range Range("Y11:BR41").Select Set A = Worksheets("Summary").Range("Y11:BR41") Format_Cells (A) --------------------------------------------------------------- Function --------------------------------------------------------------- Function Format_Cells(A As Range) With Selection.Borders(xlEdgeLeft) LineStyle = xlContinuous Weight = xlThin ColorIndex = 16 End With With Selection.Borders(xlEdgeTop) LineStyle = xlContinuous Weight = xlThin ColorIndex = 16 End With With Selection.Borders(xlEdgeBottom) LineStyle = xlContinuous Weight = xlThin ColorIndex = 2 End With With Selection.Borders(xlEdgeRight) LineStyle = xlContinuous Weight = xlThin ColorIndex = 2 End With With Selection.Borders(xlInsideVertical) LineStyle = xlContinuous Weight = xlHairline ColorIndex = 16 End With With Selection.Borders(xlInsideHorizontal) LineStyle = xlContinuous Weight = xlHairline ColorIndex = 16 End With With Selection.Interior ColorIndex = 19 Pattern = xlSolid PatternColorIndex = xlAutomatic End With With Selection.Font Name = "Tahoma" FontStyle = "Regular" Size = 8 ColorIndex = xlAutomatic End With End Function ---------------------------------------------------------------- -- Baapi ------------------------------------------------------------------------ Baapi's Profile: http://www.excelforum.com/member.php...o&userid=27333 View this thread: http://www.excelforum.com/showthread...hreadid=469377 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Malfunction formulae | Excel Discussion (Misc queries) | |||
Help Excel malfunction | Excel Discussion (Misc queries) | |||
pPMT malfunction | Excel Worksheet Functions | |||
AutoSum malfunction | Charts and Charting in Excel | |||
Code malfunction | Excel Programming |