Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default how to subtract a range from another?

say i wanna set a range of an entire column "minus" first 4 rows. How to do
this in VBA?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default how to subtract a range from another?

One way:

Dim rng As Range
Set rng = Range(Cells(5, 1), Cells(Rows.Count, 1))
MsgBox rng.Address

Hope this helps
Rowan

serdar wrote:
say i wanna set a range of an entire column "minus" first 4 rows. How to do
this in VBA?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default how to subtract a range from another?

thats ok.when i use this range as:

rng.Find(x, LookIn:=xlValues)

all 65536 cell are searched? or just searches until the last used/formatted?


"Rowan Drummond" , haber iletisinde sunlari
...
One way:

Dim c As Range
Set rng = Range(Cells(5, 1), Cells(Rows.Count, 1))
MsgBox rng.Address

Hope this helps
Rowan

serdar wrote:
say i wanna set a range of an entire column "minus" first 4 rows. How to
do this in VBA?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default how to subtract a range from another?

I guess it would search the whole range. An alternative would be:

Dim eRow As Long
Dim rng As Range
eRow = Cells(Rows.Count, 1).End(xlUp).Row
If eRow 4 Then
Set rng = Range(Cells(5, 1), Cells(eRow, 1))
MsgBox rng.Address
End If

Regards
Rowan

serdar wrote:
thats ok.when i use this range as:

rng.Find(x, LookIn:=xlValues)

all 65536 cell are searched? or just searches until the last used/formatted?


"Rowan Drummond" , haber iletisinde sunlari
...

One way:

Dim c As Range
Set rng = Range(Cells(5, 1), Cells(Rows.Count, 1))
MsgBox rng.Address

Hope this helps
Rowan

serdar wrote:

say i wanna set a range of an entire column "minus" first 4 rows. How to
do this in VBA?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to subtract a range from another?

Just to the last used/formatted.

--
Regards,
Tom Ogilvy

"serdar" wrote in message
...
thats ok.when i use this range as:

rng.Find(x, LookIn:=xlValues)

all 65536 cell are searched? or just searches until the last

used/formatted?


"Rowan Drummond" , haber iletisinde sunlari
...
One way:

Dim c As Range
Set rng = Range(Cells(5, 1), Cells(Rows.Count, 1))
MsgBox rng.Address

Hope this helps
Rowan

serdar wrote:
say i wanna set a range of an entire column "minus" first 4 rows. How

to
do this in VBA?







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to subtract a range from another?

Actually it just searches until the first value is found, but would only
search in the specified range.

Rowan has shown additional code to ensure there is data below row 4.

--
Regards,
Tom Ogilvy


"serdar" wrote in message
...
thats ok.when i use this range as:

rng.Find(x, LookIn:=xlValues)

all 65536 cell are searched? or just searches until the last

used/formatted?


"Rowan Drummond" , haber iletisinde sunlari
...
One way:

Dim c As Range
Set rng = Range(Cells(5, 1), Cells(Rows.Count, 1))
MsgBox rng.Address

Hope this helps
Rowan

serdar wrote:
say i wanna set a range of an entire column "minus" first 4 rows. How

to
do this in VBA?





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to subtract a range from another?

another way to protect for blanks below row 4 is

set rng = Range(cells(1,1),cells(rows.count,1).End(xlup))
if rng.count <= 4 then
set rng = Range("A5")
else
set rng = rng.offset(4,0).Resize(rng.count-4,1)
end if

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Actually it just searches until the first value is found, but would only
search in the specified range.

Rowan has shown additional code to ensure there is data below row 4.

--
Regards,
Tom Ogilvy


"serdar" wrote in message
...
thats ok.when i use this range as:

rng.Find(x, LookIn:=xlValues)

all 65536 cell are searched? or just searches until the last

used/formatted?


"Rowan Drummond" , haber iletisinde sunlari
...
One way:

Dim c As Range
Set rng = Range(Cells(5, 1), Cells(Rows.Count, 1))
MsgBox rng.Address

Hope this helps
Rowan

serdar wrote:
say i wanna set a range of an entire column "minus" first 4 rows. How

to
do this in VBA?







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
I want to add or subtract a range of cells wormburner Excel Discussion (Misc queries) 2 May 31st 10 11:03 PM
trying to subtract a range from a cell Angel Woman Excel Worksheet Functions 1 March 26th 09 08:26 PM
subtract a range from an added range Marge Excel Discussion (Misc queries) 2 November 20th 08 10:09 PM
I need to subtract a range of numbers natashac Excel Worksheet Functions 5 October 2nd 07 01:32 AM
How to subtract some rows from a range Simon Lenn Excel Programming 3 March 5th 04 01:16 PM


All times are GMT +1. The time now is 04:59 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"