ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Resize selection made by "name" VBA (https://www.excelbanter.com/excel-discussion-misc-queries/67477-resize-selection-made-name-vba.html)

spydor

Resize selection made by "name" VBA
 

Hi...Thanks for your help!!!

The problem is thussly.....

I have selected a range by "name" and I need to delete some of it's
contents without losing the top and bottom lines which are the location
lines for finding the "name" range. Got any clean, simple ways to do
this????
Thanks....
Spydor


--
spydor
------------------------------------------------------------------------
spydor's Profile: http://www.excelforum.com/member.php...o&userid=28438
View this thread: http://www.excelforum.com/showthread...hreadid=505183


Dave Peterson

Resize selection made by "name" VBA
 
Without knowing too much...

Dim myRng As Range
Dim iRow As Long

Set myRng = Worksheets("sheet1").Range("testrng")

'keep first and last
For iRow = myRng.Rows.Count - 1 To 2 Step -1
myRng.Rows(iRow).EntireRow.Delete
Next iRow




spydor wrote:

Hi...Thanks for your help!!!

The problem is thussly.....

I have selected a range by "name" and I need to delete some of it's
contents without losing the top and bottom lines which are the location
lines for finding the "name" range. Got any clean, simple ways to do
this????
Thanks....
Spydor

--
spydor
------------------------------------------------------------------------
spydor's Profile: http://www.excelforum.com/member.php...o&userid=28438
View this thread: http://www.excelforum.com/showthread...hreadid=505183


--

Dave Peterson

paul

Resize selection made by "name" VBA
 
knowing MUCH less than David,have you seen the VBA resize property

Resize Property
Resizes the specified range. Returns a Range object that represents the
resized range.

expression.Resize(RowSize, ColumnSize)
expression Required. An expression that returns a Range object to be
resized.

RowSize Optional Variant. The number of rows in the new range. If this
argument is omitted, the number of rows in the range remains the same.

ColumnSize Optional Variant. The number of columns in the new range. If
this argument is omitted, the number of columns in the range remains the same.

Example
This example resizes the selection on Sheet1 to extend it by one row and one
column.

Worksheets("Sheet1").Activate
numRows = Selection.Rows.Count
numColumns = Selection.Columns.Count
Selection.Resize(numRows + 1, numColumns

--
paul
remove nospam for email addy!



"Dave Peterson" wrote:

Without knowing too much...

Dim myRng As Range
Dim iRow As Long

Set myRng = Worksheets("sheet1").Range("testrng")

'keep first and last
For iRow = myRng.Rows.Count - 1 To 2 Step -1
myRng.Rows(iRow).EntireRow.Delete
Next iRow




spydor wrote:

Hi...Thanks for your help!!!

The problem is thussly.....

I have selected a range by "name" and I need to delete some of it's
contents without losing the top and bottom lines which are the location
lines for finding the "name" range. Got any clean, simple ways to do
this????
Thanks....
Spydor

--
spydor
------------------------------------------------------------------------
spydor's Profile: http://www.excelforum.com/member.php...o&userid=28438
View this thread: http://www.excelforum.com/showthread...hreadid=505183


--

Dave Peterson



All times are GMT +1. The time now is 03:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com