Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Variable range

Hello, I need help with code.

I have a macro that I use to process each calling card account's information.

A B C D
etc.
Date Number_dialed Location Duration

all columns have the same number of rows, but this number changes depending
of the amount of calls made from each account.

I have set the fixed range in my macro from 2:3800, but most of the time the
number of raws do'nt exceed 1000

Is there a way to just process the number of raws in each account instead of
going the full 3800?

Your help will be grately apreciated

Regards
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Variable range

instead of 3800 do this:
add these 2 lines at the top of the code:

dim ws as worksheet
dim lastrow as long

then add these 2 lines:
set ws = worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

then for your range use this:

ws.range("A2:A" & lastrow)

i like to qualify the ranges with the sheet name, i used sheet1, use whatever
your sheet name is.
i used column A in the lastrow statement, use whatever column you are using.

--


Gary


"farid2001" wrote in message
...
Hello, I need help with code.

I have a macro that I use to process each calling card account's information.

A B C D
etc.
Date Number_dialed Location Duration

all columns have the same number of rows, but this number changes depending
of the amount of calls made from each account.

I have set the fixed range in my macro from 2:3800, but most of the time the
number of raws do'nt exceed 1000

Is there a way to just process the number of raws in each account instead of
going the full 3800?

Your help will be grately apreciated

Regards



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Variable range

Thank you very much Gary, your code worked very well!!
Regards
farid2001

"Gary Keramidas" wrote:

instead of 3800 do this:
add these 2 lines at the top of the code:

dim ws as worksheet
dim lastrow as long

then add these 2 lines:
set ws = worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

then for your range use this:

ws.range("A2:A" & lastrow)

i like to qualify the ranges with the sheet name, i used sheet1, use whatever
your sheet name is.
i used column A in the lastrow statement, use whatever column you are using.

--


Gary


"farid2001" wrote in message
...
Hello, I need help with code.

I have a macro that I use to process each calling card account's information.

A B C D
etc.
Date Number_dialed Location Duration

all columns have the same number of rows, but this number changes depending
of the amount of calls made from each account.

I have set the fixed range in my macro from 2:3800, but most of the time the
number of raws do'nt exceed 1000

Is there a way to just process the number of raws in each account instead of
going the full 3800?

Your help will be grately apreciated

Regards




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Variable range

RngEnd = Range("A1").End(xlDown).Row
gives the No of the last used row. Use this No in cell references, e.g.
Range("A" & RngEnd) instead of Range("A3800")

Regards,
Stefi

€˛farid2001€¯ ezt Ć*rta:

Hello, I need help with code.

I have a macro that I use to process each calling card account's information.

A B C D
etc.
Date Number_dialed Location Duration

all columns have the same number of rows, but this number changes depending
of the amount of calls made from each account.

I have set the fixed range in my macro from 2:3800, but most of the time the
number of raws do'nt exceed 1000

Is there a way to just process the number of raws in each account instead of
going the full 3800?

Your help will be grately apreciated

Regards

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Variable range

Stefi
Thank you very much, your code worked very well!!

Regards
farid2001

"Stefi" wrote:

RngEnd = Range("A1").End(xlDown).Row
gives the No of the last used row. Use this No in cell references, e.g.
Range("A" & RngEnd) instead of Range("A3800")

Regards,
Stefi

€˛farid2001€¯ ezt Ć*rta:

Hello, I need help with code.

I have a macro that I use to process each calling card account's information.

A B C D
etc.
Date Number_dialed Location Duration

all columns have the same number of rows, but this number changes depending
of the amount of calls made from each account.

I have set the fixed range in my macro from 2:3800, but most of the time the
number of raws do'nt exceed 1000

Is there a way to just process the number of raws in each account instead of
going the full 3800?

Your help will be grately apreciated

Regards



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Variable range

You are welcome! Thanks for the feedback!
Stefi

€˛farid2001€¯ ezt Ć*rta:

Stefi
Thank you very much, your code worked very well!!

Regards
farid2001

"Stefi" wrote:

RngEnd = Range("A1").End(xlDown).Row
gives the No of the last used row. Use this No in cell references, e.g.
Range("A" & RngEnd) instead of Range("A3800")

Regards,
Stefi

€˛farid2001€¯ ezt Ć*rta:

Hello, I need help with code.

I have a macro that I use to process each calling card account's information.

A B C D
etc.
Date Number_dialed Location Duration

all columns have the same number of rows, but this number changes depending
of the amount of calls made from each account.

I have set the fixed range in my macro from 2:3800, but most of the time the
number of raws do'nt exceed 1000

Is there a way to just process the number of raws in each account instead of
going the full 3800?

Your help will be grately apreciated

Regards

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
Range to VLOOKUP as a Variable (range in another file) LuisE Excel Programming 3 December 2nd 07 03:22 PM
select range and put range address in variable [email protected] Excel Programming 2 January 25th 06 01:28 AM
Macro to copy a specified range to a variable range SWT Excel Programming 4 October 21st 05 08:24 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


All times are GMT +1. The time now is 01:29 PM.

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

About Us

"It's about Microsoft Excel"