Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to create a function that will check a cell for a bottom border and
return a 1 if True or 0 if False. My function will be in cell M15, checking cell A14 for the border. I have the following, which is returning a #NAME? error: If Range.Select.Borders(xlEdgeBottom).Weight = xlThin _ Then ActiveCell.FormulaR1C1 = "1" Else ActiveCell.FomulaR1C1 = "0" Thank you in advance for your help Marco |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If Selection.Borders(xlEdgeBottom).Weight = xlThin _
Then ActiveCell.FormulaR1C1 = "1" Else ActiveCell.FomulaR1C1 = "0" "Marco" wrote: I want to create a function that will check a cell for a bottom border and return a 1 if True or 0 if False. My function will be in cell M15, checking cell A14 for the border. I have the following, which is returning a #NAME? error: If Range.Select.Borders(xlEdgeBottom).Weight = xlThin _ Then ActiveCell.FormulaR1C1 = "1" Else ActiveCell.FomulaR1C1 = "0" Thank you in advance for your help Marco |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No go. Still getting same error.
"JLGWhiz" wrote: If Selection.Borders(xlEdgeBottom).Weight = xlThin _ Then ActiveCell.FormulaR1C1 = "1" Else ActiveCell.FomulaR1C1 = "0" "Marco" wrote: I want to create a function that will check a cell for a bottom border and return a 1 if True or 0 if False. My function will be in cell M15, checking cell A14 for the border. I have the following, which is returning a #NAME? error: If Range.Select.Borders(xlEdgeBottom).Weight = xlThin _ Then ActiveCell.FormulaR1C1 = "1" Else ActiveCell.FomulaR1C1 = "0" Thank you in advance for your help Marco |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can use a UDF like:
Option Explicit Function ThinBottomBorder(rng As Range) As Long If rng.Cells(1).Borders(xlEdgeBottom).Weight = xlThin Then ThinBottomBorder = 1 Else ThinBottomBorder = 0 End If End Function Then put this in M15: =thinbottomborder(a14) Marco wrote: I want to create a function that will check a cell for a bottom border and return a 1 if True or 0 if False. My function will be in cell M15, checking cell A14 for the border. I have the following, which is returning a #NAME? error: If Range.Select.Borders(xlEdgeBottom).Weight = xlThin _ Then ActiveCell.FormulaR1C1 = "1" Else ActiveCell.FomulaR1C1 = "0" Thank you in advance for your help Marco -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No go. Still getting the same error.
Do I need to put in "Option Explicit"? "Dave Peterson" wrote: You can use a UDF like: Option Explicit Function ThinBottomBorder(rng As Range) As Long If rng.Cells(1).Borders(xlEdgeBottom).Weight = xlThin Then ThinBottomBorder = 1 Else ThinBottomBorder = 0 End If End Function Then put this in M15: =thinbottomborder(a14) Marco wrote: I want to create a function that will check a cell for a bottom border and return a 1 if True or 0 if False. My function will be in cell M15, checking cell A14 for the border. I have the following, which is returning a #NAME? error: If Range.Select.Borders(xlEdgeBottom).Weight = xlThin _ Then ActiveCell.FormulaR1C1 = "1" Else ActiveCell.FomulaR1C1 = "0" Thank you in advance for your help Marco -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Put the entire code that I posted in its own module--Insert|Module--don't put it
in a worksheet module and don't put it under the ThisWorkbook module. Marco wrote: No go. Still getting the same error. Do I need to put in "Option Explicit"? "Dave Peterson" wrote: You can use a UDF like: Option Explicit Function ThinBottomBorder(rng As Range) As Long If rng.Cells(1).Borders(xlEdgeBottom).Weight = xlThin Then ThinBottomBorder = 1 Else ThinBottomBorder = 0 End If End Function Then put this in M15: =thinbottomborder(a14) Marco wrote: I want to create a function that will check a cell for a bottom border and return a 1 if True or 0 if False. My function will be in cell M15, checking cell A14 for the border. I have the following, which is returning a #NAME? error: If Range.Select.Borders(xlEdgeBottom).Weight = xlThin _ Then ActiveCell.FormulaR1C1 = "1" Else ActiveCell.FomulaR1C1 = "0" Thank you in advance for your help Marco -- Dave Peterson -- Dave Peterson |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No go. Did as instructed and getting same error.
"Dave Peterson" wrote: Put the entire code that I posted in its own module--Insert|Module--don't put it in a worksheet module and don't put it under the ThisWorkbook module. Marco wrote: No go. Still getting the same error. Do I need to put in "Option Explicit"? "Dave Peterson" wrote: You can use a UDF like: Option Explicit Function ThinBottomBorder(rng As Range) As Long If rng.Cells(1).Borders(xlEdgeBottom).Weight = xlThin Then ThinBottomBorder = 1 Else ThinBottomBorder = 0 End If End Function Then put this in M15: =thinbottomborder(a14) Marco wrote: I want to create a function that will check a cell for a bottom border and return a 1 if True or 0 if False. My function will be in cell M15, checking cell A14 for the border. I have the following, which is returning a #NAME? error: If Range.Select.Borders(xlEdgeBottom).Weight = xlThin _ Then ActiveCell.FormulaR1C1 = "1" Else ActiveCell.FomulaR1C1 = "0" Thank you in advance for your help Marco -- Dave Peterson -- Dave Peterson |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't think you did.
Debra Dalgleish has some notes how to implement macros he http://www.contextures.com/xlvba01.html David McRitchie has an intro to macros: http://www.mvps.org/dmcritchie/excel/getstarted.htm Ron de Bruin's intro to macros: http://www.rondebruin.nl/code.htm (General, Regular and Standard modules all describe the same thing.) Marco wrote: No go. Did as instructed and getting same error. "Dave Peterson" wrote: Put the entire code that I posted in its own module--Insert|Module--don't put it in a worksheet module and don't put it under the ThisWorkbook module. Marco wrote: No go. Still getting the same error. Do I need to put in "Option Explicit"? "Dave Peterson" wrote: You can use a UDF like: Option Explicit Function ThinBottomBorder(rng As Range) As Long If rng.Cells(1).Borders(xlEdgeBottom).Weight = xlThin Then ThinBottomBorder = 1 Else ThinBottomBorder = 0 End If End Function Then put this in M15: =thinbottomborder(a14) Marco wrote: I want to create a function that will check a cell for a bottom border and return a 1 if True or 0 if False. My function will be in cell M15, checking cell A14 for the border. I have the following, which is returning a #NAME? error: If Range.Select.Borders(xlEdgeBottom).Weight = xlThin _ Then ActiveCell.FormulaR1C1 = "1" Else ActiveCell.FomulaR1C1 = "0" Thank you in advance for your help Marco -- Dave Peterson -- Dave Peterson -- Dave Peterson |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dave's function worked fine for me. I copied his code and pasted it in my
standard code module, then I put a thin solid border on a cell in cell A4. Then in a cell in another column, I typed "ThinBottomBorder(a4)" without the quote marks, pressed enter and a 1 appeared in that cell. Maybe, if you explained how you tried his code the problem could be cleared up. "Marco" wrote: No go. Did as instructed and getting same error. "Dave Peterson" wrote: Put the entire code that I posted in its own module--Insert|Module--don't put it in a worksheet module and don't put it under the ThisWorkbook module. Marco wrote: No go. Still getting the same error. Do I need to put in "Option Explicit"? "Dave Peterson" wrote: You can use a UDF like: Option Explicit Function ThinBottomBorder(rng As Range) As Long If rng.Cells(1).Borders(xlEdgeBottom).Weight = xlThin Then ThinBottomBorder = 1 Else ThinBottomBorder = 0 End If End Function Then put this in M15: =thinbottomborder(a14) Marco wrote: I want to create a function that will check a cell for a bottom border and return a 1 if True or 0 if False. My function will be in cell M15, checking cell A14 for the border. I have the following, which is returning a #NAME? error: If Range.Select.Borders(xlEdgeBottom).Weight = xlThin _ Then ActiveCell.FormulaR1C1 = "1" Else ActiveCell.FomulaR1C1 = "0" Thank you in advance for your help Marco -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Check for # of Words in Function | Excel Worksheet Functions | |||
Please check my use of the ACCRINTM function. | Excel Worksheet Functions | |||
Check my IF function | Excel Worksheet Functions | |||
check box function? | Excel Worksheet Functions | |||
Function to set borders of cell | Excel Worksheet Functions |