|
-
Mar 27th, 2007, 01:56 PM
#1
Thread Starter
Addicted Member
Searching for interior color and borders
I'd like to find the last row that contains any one of the following things:
- Text
- Interior color
- Borders
This construct:
Code:
with wks
lastRow = .Columns(col).Find("*", SearchOrder:=xlByRows, _
LookIn:=xlValues, SearchDirection:=xlPrevious).row
end with
seems to only find text. I can accomplish my goal by looping over each cell in the column, something like (untested):
Code:
Dim i as integer
with wks
for i = 65535 to 1 step -1
if not isEmpty(.cells(i,col)) and .cells(i,col).interior.colorIndex <> xlNone then _
exit for
next i
end with
msgbox("Last row with anything is " + str(i))
I don't know how to tell if there's a border, but in principle I can Google for it, and if I can't find it, ask here, and use it as a third condition in the conditional.
If there a faster or shorter way of doing this?
Thanks!
-
Mar 27th, 2007, 05:19 PM
#2
Re: Searching for interior color and borders
I don't know how to tell if there's a border
Does this help?
vb Code:
'Example for cell A1
If Range("A1").BorderAround = True Then
MsgBox "This cell has a border"
End If
If there a faster or shorter way of doing this?
Tip: If you loop through all the 65536 cells then excel will be damn slow. Check out "SpecialCells Method" in VBA Help to find the last cell. Then you can combine both to get the desired result...
Last edited by Siddharth Rout; Mar 27th, 2007 at 05:23 PM.
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|