Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Get Last Unused Cell

I am trying to get the last unused cell so that I can put a borde
around them. This is because my result set in the worksheet is dynami
and can contain more or less values. Right now I have macro hard-codin
the last cell in the range:
Range("A1:H16").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

How do I find he last unused cell in my range cell property? Thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Get Last Unused Cell

Hi

One way :

Look on Debra's site for a dynamic range
http://www.contextures.com/xlNames01.html#Dynamic

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Session101 " wrote in message ...
I am trying to get the last unused cell so that I can put a border
around them. This is because my result set in the worksheet is dynamic
and can contain more or less values. Right now I have macro hard-coding
the last cell in the range:
Range("A1:H16").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
LineStyle = xlContinuous
Weight = xlThin
ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
LineStyle = xlContinuous
Weight = xlThin
ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
LineStyle = xlContinuous
Weight = xlThin
ColorIndex = xlAutomatic
End With

How do I find he last unused cell in my range cell property? Thanks!


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Get Last Unused Cell

I am trying to get the last unused cell so that I can put a borde
around them. This is because my result set in the worksheet is dynami
and can contain more or less values. Right now I have macro hard-codin
the last cell in the range:
Range("A1:H16").Select

You may use:
1)
With ActiveCell.CurrentRegion
.BorderAround ColorIndex:=xlAutomatic, Weight:=xlThin
.Borders(xlInsideVertical).Weight = xlThin
.Borders(xlInsideVertical).ColorIndex = xlAutomatic
.Borders(xlInsideHorizontal).Weight = xlThin
.Borders(xlInsideHorizontal).ColorIndex = xlAutomatic
End With
This will format the current cells borders
2)

'usually yuo will always have the headers of your work non dinamic
anyway
and you will add new record, I mean rows to it
One of the columns usually is the key, a value is mandatory
say column (A:A) "Name"
usually A is the column to look after

Sub TryThis()
Dim Rg As Range
Set Rg = Range("A4")
With Range(Rg, Cells(Rg.End(xlDown).Row
Rg.End(xlToRight).Column))
.Select
.BorderAround ColorIndex:=xlAutomatic, Weight:=xlThin
.Borders(xlInsideVertical).Weight = xlThin
.Borders(xlInsideVertical).ColorIndex = xlAutomatic
.Borders(xlInsideHorizontal).Weight = xlThin
.Borders(xlInsideHorizontal).ColorIndex = xlAutomatic
End With

End Su

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find column letter of the first unused cell John Excel Worksheet Functions 2 May 10th 09 09:06 PM
Copying to next unused row Ken[_2_] Excel Worksheet Functions 5 June 24th 08 08:11 AM
what to do with unused cells B Excel Worksheet Functions 1 June 22nd 06 12:09 AM
Code not going to next unused row goss[_30_] Excel Programming 2 August 9th 04 05:04 AM
find next unused row Mike[_33_] Excel Programming 2 July 16th 03 05:01 AM


All times are GMT +1. The time now is 07:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"