Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to specify a Range which includes an integer variable

The following code works, but it is probably 3 times as long as it needs to
be:

Sheets("Printed").Range("O8:O27,I4:I5").ClearConte nts
Select Case gintRoundN
Case 1: Sheets("Votes").Range("E21:K30").ClearContents
Case 2: Sheets("Votes").Range("F21:K30").ClearContents
Case 3: Sheets("Votes").Range("G21:K30").ClearContents
Case 4: Sheets("Votes").Range("H21:K30").ClearContents
Case 5: Sheets("Votes").Range("I21:K30").ClearContents
Case 6: Sheets("Votes").Range("J21:K30").ClearContents
Case 7: Sheets("Votes").Range("K21:K30").ClearContents
End Select

What I really want is to find a way of inserting a letter as the first
character of the Range ("*21:K30) with E corresponding to 1, F to 2 etc.
Can anyone put me out of my misery?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default How to specify a Range which includes an integer variable

How about something like this:

Sheets("Votes").Range(Chr$(gintRoundN + 68) & "21:K30").ClearContents

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Hotbird" wrote in message
...
The following code works, but it is probably 3 times as long as it needs

to
be:

Sheets("Printed").Range("O8:O27,I4:I5").ClearConte nts
Select Case gintRoundN
Case 1: Sheets("Votes").Range("E21:K30").ClearContents
Case 2: Sheets("Votes").Range("F21:K30").ClearContents
Case 3: Sheets("Votes").Range("G21:K30").ClearContents
Case 4: Sheets("Votes").Range("H21:K30").ClearContents
Case 5: Sheets("Votes").Range("I21:K30").ClearContents
Case 6: Sheets("Votes").Range("J21:K30").ClearContents
Case 7: Sheets("Votes").Range("K21:K30").ClearContents
End Select

What I really want is to find a way of inserting a letter as the first
character of the Range ("*21:K30) with E corresponding to 1, F to 2 etc.
Can anyone put me out of my misery?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to specify a Range which includes an integer variable

Many thanks for this elegant solution

"Rob Bovey" wrote in message
...
How about something like this:

Sheets("Votes").Range(Chr$(gintRoundN + 68) & "21:K30").ClearContents

--



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to specify a Range which includes an integer variable

Hello Rob,

Could you please explain the syntax you suggest he (Chr$(gintRound
+ 68) & "21:K30")

In particular ... what is "Chr$"?

Thank

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default How to specify a Range which includes an integer variable

Hi
try something like

col_index = 1
Case 1:
Sheets("Votes").Range(cells(21,col_index+4),cells( 30,11)).ClearContents


--
Regards
Frank Kabel
Frankfurt, Germany


Hotbird wrote:
The following code works, but it is probably 3 times as long as it
needs to be:

Sheets("Printed").Range("O8:O27,I4:I5").ClearConte nts
Select Case gintRoundN
Case 1: Sheets("Votes").Range("E21:K30").ClearContents
Case 2: Sheets("Votes").Range("F21:K30").ClearContents
Case 3: Sheets("Votes").Range("G21:K30").ClearContents
Case 4: Sheets("Votes").Range("H21:K30").ClearContents
Case 5: Sheets("Votes").Range("I21:K30").ClearContents
Case 6: Sheets("Votes").Range("J21:K30").ClearContents
Case 7: Sheets("Votes").Range("K21:K30").ClearContents
End Select

What I really want is to find a way of inserting a letter as the

first
character of the Range ("*21:K30) with E corresponding to 1, F to 2
etc. Can anyone put me out of my misery?




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
=max(range includes #N/As) David Excel Worksheet Functions 3 September 14th 05 05:00 PM
Is variable an integer? Otto Moehrbach[_6_] Excel Programming 7 February 6th 04 04:31 PM
OutlineLevel and Integer Variable issue jurgenC![_2_] Excel Programming 2 January 30th 04 10:32 PM
Scope of variable includes all Form _and_ Code modules?? John Wirt[_2_] Excel Programming 5 August 18th 03 08:27 AM
Use of integer variable for sizing of matrix Cor Steeghs Excel Programming 2 August 8th 03 12:56 PM


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