![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 19
|
I am trying to format a cell (place solid outline around it) if another cell in that row isn't blank. However the column of possibly filled cells varies from worksheet to worksheet.
This is driving me so nuts I can't explain it properly either. all help gratefully rec'd |
|
|
|
|
|
#2 |
|
New Member
Join Date: May 2002
Posts: 34
|
Do the columns of "possibly filled cells" have anything in common (e.g. header at the top, value if filled) that is exclusive to those columns?
It's difficult to visualise what you are trying to do. Andrew |
|
|
|
|
|
#3 |
|
New Member
Join Date: May 2002
Posts: 19
|
I have sub totalled a range of information, where the **** total appears in a row, say cell D5 - I want to format cell J5 with a solid outline.
|
|
|
|
|
|
#4 |
|
New Member
Join Date: May 2002
Posts: 34
|
Conditional formatting won't work, as far as I know.
It can be done with a macro, but that would either mean running the macro on an event (e.g. every time you change cell selection - this could be limited to checking just that row) or doing the check manually (e.g. press a button). How this is scripted depends on how you want it to function. |
|
|
|
|
|
#5 |
|
New Member
Join Date: May 2002
Posts: 19
|
The info changes daily, it is sorted and then printed, the formatted cells give a 'tick box' on the hard copy, so a macro would probably be ok, but I don't know where to start.
|
|
|
|
|
|
#6 |
|
New Member
Join Date: May 2002
Posts: 34
|
This will need editing to suit your needs.
Try it and see what changes you want. If you need more help, just ask. Sub format() ' Declare Variables Dim cellToFormat Dim cellToCheck Dim columnToFormat Dim columnToCheck Dim rowNumber 'Set Column to Format columnToFormat = "J" 'Set Column to Check columnToCheck = "D" 'Set Number of Rows to Format rowNumber = 1000 ' For loop to check D column and format J column For i = 1 To rowNumber cellToCheck = columnToCheck & i If Not (Range(cellToCheck).Value = "") Then cellToFormat = columnToFormat & i With Range(cellToFormat).Borders(xlEdgeLeft) End With With Range(cellToFormat).Borders(xlEdgeTop) End With With Range(cellToFormat).Borders(xlEdgeBottom) End With With Range(cellToFormat).Borders(xlEdgeRight) End With End If Next i End Sub |
|
|
|
|
|
#7 |
|
New Member
Join Date: May 2002
Posts: 34
|
Apologies - missed out the weighting of the borders:
.Weight = xlThin or .Weight = xlThick This line goes directly under each border setting: With Range(cellToFormat).Borders(xlEdgeLeft) .Weight = xlThin |
|
|
|
|
|
#8 |
|
New Member
Join Date: May 2002
Posts: 19
|
Thanks very much, I'll try it out and let you know when I get back to work.
I wish I'd asked here first !! |
|
|
|
|
|
#9 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
|
Quote:
from your code it looks like: in column J 1-1000 Conditional Formating>Formula is =ISNUMBER($D1) should be the same. With regards to the orignal question. Is the formatting only to be done in the row with a SUBTOTAL with other numbers above?
__________________
"Have a good time......all the time" Ian Mac |
|
|
|
|
|
|
#10 | |
|
New Member
Join Date: May 2002
Posts: 34
|
Quote:
Cheers Andrew |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|