Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Beginner question about selecting a range

Greetings!

I am in the process of teaching myself VBA using Excel 97. The logic of
coding doesn't bother me, but the syntax is another story.

Let me present a simplified example of a coding effort. I'm trying to get
Excel to select a range based on some user inputs.

Private Sub cmd1_form1_Click()

Dim StartCell As String `Maybe a different variable type here?
Dim NumColumns As Integer
Dim NumRows As Integer

StartCell = txt1_form1.Text
NumColumns = txt2_form1.Text
NumRows = txt3_form1.Text

` txt4_form1.Text = StartCell & " " & NumColumns & " " _
NumRows

Range(?????).Select 'This is what I'm after

End Sub

I did the easy part and built the form for entering these values, and I can
display the entered values in a fourth text box, but what I really want to
do is select the range specified by these user entered values, i.e. if the
user enters A1,4,6 then I want Excel to select the range A1:D6.

I'm somewhat familiar with the Range(argument).Select function, but I can't
figure out how to perform the necessary calculations on the initial cell
reference entered by the user.

I'm thinking I may need to make better choices for the value types entered
by the user (maybe string, integer, integer are not good choices).

Could anyone post a simple block of code that will perform the example I
described above?

This is a simple example to help me get comfortable conceptually. My true
mini-goal is to merely have the user specify a starting cell and then have
the code determine the extents of a table already present on a worksheet.

Any tips or suggestions greatly appreciated - TIA!

-gk-


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Beginner question about selecting a range

Hi,

I have a guide with the basic syntax of selecting ranges at

http://hologuides.com/programming/ExcelVBA


"TBA" schrieb im Newsbeitrag
...
Greetings!

I am in the process of teaching myself VBA using Excel 97. The logic of
coding doesn't bother me, but the syntax is another story.

Let me present a simplified example of a coding effort. I'm trying to get
Excel to select a range based on some user inputs.

Private Sub cmd1_form1_Click()

Dim StartCell As String `Maybe a different variable type here?
Dim NumColumns As Integer
Dim NumRows As Integer

StartCell = txt1_form1.Text
NumColumns = txt2_form1.Text
NumRows = txt3_form1.Text

` txt4_form1.Text = StartCell & " " & NumColumns & " " _
NumRows

Range(?????).Select 'This is what I'm after

End Sub

I did the easy part and built the form for entering these values, and I

can
display the entered values in a fourth text box, but what I really want to
do is select the range specified by these user entered values, i.e. if the
user enters A1,4,6 then I want Excel to select the range A1:D6.

I'm somewhat familiar with the Range(argument).Select function, but I

can't
figure out how to perform the necessary calculations on the initial cell
reference entered by the user.

I'm thinking I may need to make better choices for the value types entered
by the user (maybe string, integer, integer are not good choices).

Could anyone post a simple block of code that will perform the example I
described above?

This is a simple example to help me get comfortable conceptually. My true
mini-goal is to merely have the user specify a starting cell and then have
the code determine the extents of a table already present on a worksheet.

Any tips or suggestions greatly appreciated - TIA!

-gk-




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Beginner question about selecting a range

Range(StartCell, Range(StartCell)(NumRows, NumColumns)).Select

Alan Beban

TBA wrote:
Greetings!

I am in the process of teaching myself VBA using Excel 97. The logic of
coding doesn't bother me, but the syntax is another story.

Let me present a simplified example of a coding effort. I'm trying to get
Excel to select a range based on some user inputs.

Private Sub cmd1_form1_Click()

Dim StartCell As String `Maybe a different variable type here?
Dim NumColumns As Integer
Dim NumRows As Integer

StartCell = txt1_form1.Text
NumColumns = txt2_form1.Text
NumRows = txt3_form1.Text

` txt4_form1.Text = StartCell & " " & NumColumns & " " _
NumRows

Range(?????).Select 'This is what I'm after

End Sub

I did the easy part and built the form for entering these values, and I can
display the entered values in a fourth text box, but what I really want to
do is select the range specified by these user entered values, i.e. if the
user enters A1,4,6 then I want Excel to select the range A1:D6.

I'm somewhat familiar with the Range(argument).Select function, but I can't
figure out how to perform the necessary calculations on the initial cell
reference entered by the user.

I'm thinking I may need to make better choices for the value types entered
by the user (maybe string, integer, integer are not good choices).

Could anyone post a simple block of code that will perform the example I
described above?

This is a simple example to help me get comfortable conceptually. My true
mini-goal is to merely have the user specify a starting cell and then have
the code determine the extents of a table already present on a worksheet.

Any tips or suggestions greatly appreciated - TIA!

-gk-



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Beginner question about selecting a range

Range(StartCell).Resize(NumRows,NumColumns).Select

as for your goal:
Range(StartCell).CurrentRegion.Select

Also
Using the refedit control allows the user to select the range using the
mouse.

--
Regards,
Tom Ogilvy

"TBA" wrote in message
...
Greetings!

I am in the process of teaching myself VBA using Excel 97. The logic of
coding doesn't bother me, but the syntax is another story.

Let me present a simplified example of a coding effort. I'm trying to get
Excel to select a range based on some user inputs.

Private Sub cmd1_form1_Click()

Dim StartCell As String `Maybe a different variable type here?
Dim NumColumns As Integer
Dim NumRows As Integer

StartCell = txt1_form1.Text
NumColumns = txt2_form1.Text
NumRows = txt3_form1.Text

` txt4_form1.Text = StartCell & " " & NumColumns & " " _
NumRows

Range(?????).Select 'This is what I'm after

End Sub

I did the easy part and built the form for entering these values, and I

can
display the entered values in a fourth text box, but what I really want to
do is select the range specified by these user entered values, i.e. if the
user enters A1,4,6 then I want Excel to select the range A1:D6.

I'm somewhat familiar with the Range(argument).Select function, but I

can't
figure out how to perform the necessary calculations on the initial cell
reference entered by the user.

I'm thinking I may need to make better choices for the value types entered
by the user (maybe string, integer, integer are not good choices).

Could anyone post a simple block of code that will perform the example I
described above?

This is a simple example to help me get comfortable conceptually. My true
mini-goal is to merely have the user specify a starting cell and then have
the code determine the extents of a table already present on a worksheet.

Any tips or suggestions greatly appreciated - TIA!

-gk-




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
Formula question from beginner JPorter Excel Discussion (Misc queries) 3 May 2nd 08 06:41 PM
Beginner Question Bernie Charts and Charting in Excel 0 February 13th 07 04:31 PM
Beginner question! Pat Excel Discussion (Misc queries) 3 August 7th 06 09:19 AM
Beginner question Tom. Excel Discussion (Misc queries) 1 April 24th 06 06:08 AM


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