Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Very Easy...Right?

How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

....to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained in A4
as the input for the already existing code.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Very Easy...Right?

i'd use something like this

mynum = Worksheets("Sheet1").Range("A4").value


--


Gary Keramidas
Excel 2003


"MovingBeyondtheRecordButton"
.com wrote in message
...
How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained in
A4
as the input for the already existing code.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 342
Default Very Easy...Right?

Try this:
mynum = Worksheets("Sheet1").Range("A4").Value

Tom


"MovingBeyondtheRecordButton" wrote:

How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained in A4
as the input for the already existing code.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Very Easy...Right?

Thanks...that works perfectly! Now that I have it working for one cell I
need to start working on making it loop for the Range("A44:A40").

"tompl" wrote:

Try this:
mynum = Worksheets("Sheet1").Range("A4").Value

Tom


"MovingBeyondtheRecordButton" wrote:

How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained in A4
as the input for the already existing code.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Very Easy...Right?

Your second one looks like it should have worked provided, of course, that
the name of your first sheet is Sheet1 (with no space between the "t" and
the "1"). As others have posted, you could have Range("A4") instead of
Cells(4,1)... I find the Cells form of referencing a range useful when
iterating either rows or columns in a loop.

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained in
A4
as the input for the already existing code.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Very Easy...Right?

A44:A40 looks backwards for a range designation although Excel will
straighten it out to A40:A44). Anyway, you can try something like this...

For Each R In Range("A40:A44")

Using R (which should be declared as a Range variable) inside the loop to
reference each cell inside the range individually. You could also do this
(provided your cells are all in a single column)...

For X = 40 To 44

and use Cells(X, "A") to reference each individual cell in the range.

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
Thanks...that works perfectly! Now that I have it working for one cell I
need to start working on making it loop for the Range("A44:A40").

"tompl" wrote:

Try this:
mynum = Worksheets("Sheet1").Range("A4").Value

Tom


"MovingBeyondtheRecordButton" wrote:

How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained
in A4
as the input for the already existing code.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 342
Default Very Easy...Right?

There are many ways to create a loop, something like this might work:

Sub LoopIt()

Dim lng As Long

For lng = 40 To 44

Debug.Print Worksheets("Sheet1").Range("A" & lng)
'Your code goes here.
Next lng


End Sub


"MovingBeyondtheRecordButton" wrote:

Thanks...that works perfectly! Now that I have it working for one cell I
need to start working on making it loop for the Range("A44:A40").

"tompl" wrote:

Try this:
mynum = Worksheets("Sheet1").Range("A4").Value

Tom


"MovingBeyondtheRecordButton" wrote:

How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained in A4
as the input for the already existing code.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Very Easy...Right?

You are right I must have not put Value on the end of that statement when I
originally tried it. I have the macro correctly pulling from our sql
database and putting the data in Sheet3 just like I wanted. Thanks.

What if I wanted to make the macro loop over the Range A4 to A40?

The procedure is...

For each number from each cell in range
Data is pulled from sql database
The output from each loop goes to Sheet3
Countif Calculations get performed
Data from Calculations go into Sheet2
Sheet3 gets cleared
Loop

"Don Guillett" wrote:


I see no reason that your second one would not work
mynum = Worksheets("Sheet1").Cells(4,1).Value

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"MovingBeyondtheRecordButton"
.com wrote in message
...
How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained in
A4
as the input for the already existing code.


.

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Very Easy...Right?

I don't understand this bit of code

Debug.Print Worksheets("Sheet1").Range("A" & lng)

What does it do? I don't want to print the data. I have the data output
into sheet3. Then the macro performs Countif calculations on that data I and
puts the results into sheet2. Sheet3 gets cleared then the macro repeats
until I have a table of data in sheet2.


"tompl" wrote:

There are many ways to create a loop, something like this might work:

Sub LoopIt()

Dim lng As Long

For lng = 40 To 44

Debug.Print Worksheets("Sheet1").Range("A" & lng)
'Your code goes here.
Next lng


End Sub


"MovingBeyondtheRecordButton" wrote:

Thanks...that works perfectly! Now that I have it working for one cell I
need to start working on making it loop for the Range("A44:A40").

"tompl" wrote:

Try this:
mynum = Worksheets("Sheet1").Range("A4").Value

Tom


"MovingBeyondtheRecordButton" wrote:

How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained in A4
as the input for the already existing code.



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Very Easy...Right?

That was a typo...it should have said Range A4:A40

"Rick Rothstein" wrote:

A44:A40 looks backwards for a range designation although Excel will
straighten it out to A40:A44). Anyway, you can try something like this...

For Each R In Range("A40:A44")

Using R (which should be declared as a Range variable) inside the loop to
reference each cell inside the range individually. You could also do this
(provided your cells are all in a single column)...

For X = 40 To 44

and use Cells(X, "A") to reference each individual cell in the range.

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
Thanks...that works perfectly! Now that I have it working for one cell I
need to start working on making it loop for the Range("A44:A40").

"tompl" wrote:

Try this:
mynum = Worksheets("Sheet1").Range("A4").Value

Tom


"MovingBeyondtheRecordButton" wrote:

How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained
in A4
as the input for the already existing code.


.

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 342
Default Very Easy...Right?

I was just using it to test my code. debug.print prints results in the
immediates window and is helpful when testing a macro. You can delete it but
it also demostrates the code for addressing each cell in the range.
Worksheets("Sheet1").Range("A" & lng) is how each cell is addressed and you
can use it to do whatever it is you want to do.

"MovingBeyondtheRecordButton" wrote:

I don't understand this bit of code

Debug.Print Worksheets("Sheet1").Range("A" & lng)

What does it do? I don't want to print the data. I have the data output
into sheet3. Then the macro performs Countif calculations on that data I and
puts the results into sheet2. Sheet3 gets cleared then the macro repeats
until I have a table of data in sheet2.


"tompl" wrote:

There are many ways to create a loop, something like this might work:

Sub LoopIt()

Dim lng As Long

For lng = 40 To 44

Debug.Print Worksheets("Sheet1").Range("A" & lng)
'Your code goes here.
Next lng


End Sub


"MovingBeyondtheRecordButton" wrote:

Thanks...that works perfectly! Now that I have it working for one cell I
need to start working on making it loop for the Range("A44:A40").

"tompl" wrote:

Try this:
mynum = Worksheets("Sheet1").Range("A4").Value

Tom


"MovingBeyondtheRecordButton" wrote:

How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained in A4
as the input for the already existing code.

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Very Easy...Right?

I just wanted to say thank you...I have been stumped...I have needed the
code....

For Each R In Range("A4:A40")

The data is really in two columns.
Will it work if it is... For Each R In Range("A4:A40","F4:F40")?

"Rick Rothstein" wrote:

A44:A40 looks backwards for a range designation although Excel will
straighten it out to A40:A44). Anyway, you can try something like this...

For Each R In Range("A40:A44")

Using R (which should be declared as a Range variable) inside the loop to
reference each cell inside the range individually. You could also do this
(provided your cells are all in a single column)...

For X = 40 To 44

and use Cells(X, "A") to reference each individual cell in the range.

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
Thanks...that works perfectly! Now that I have it working for one cell I
need to start working on making it loop for the Range("A44:A40").

"tompl" wrote:

Try this:
mynum = Worksheets("Sheet1").Range("A4").Value

Tom


"MovingBeyondtheRecordButton" wrote:

How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already contained
in A4
as the input for the already existing code.


.

  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Very Easy...Right?

Yes, that For Each loop will work on a non-contiguous range (as long as the
order of iteration is not important), but you have not specified the Range
correctly for that non-contiguous range. As written, your range will equate
to A4:F40 because you specified each range as individual String values
separated by a comma... to have the Range evaluated as A4:A40 and F4:F40,
you need to write it as a **single** String value like this...

For Each R In Range("A4:A40,F4:F40")

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
I just wanted to say thank you...I have been stumped...I have needed the
code....

For Each R In Range("A4:A40")

The data is really in two columns.
Will it work if it is... For Each R In Range("A4:A40","F4:F40")?

"Rick Rothstein" wrote:

A44:A40 looks backwards for a range designation although Excel will
straighten it out to A40:A44). Anyway, you can try something like this...

For Each R In Range("A40:A44")

Using R (which should be declared as a Range variable) inside the loop to
reference each cell inside the range individually. You could also do this
(provided your cells are all in a single column)...

For X = 40 To 44

and use Cells(X, "A") to reference each individual cell in the range.

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
Thanks...that works perfectly! Now that I have it working for one cell
I
need to start working on making it loop for the Range("A44:A40").

"tompl" wrote:

Try this:
mynum = Worksheets("Sheet1").Range("A4").Value

Tom


"MovingBeyondtheRecordButton" wrote:

How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number
already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already
contained
in A4
as the input for the already existing code.


.

  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Very Easy...Right?

Thanks again.

"Rick Rothstein" wrote:

Yes, that For Each loop will work on a non-contiguous range (as long as the
order of iteration is not important), but you have not specified the Range
correctly for that non-contiguous range. As written, your range will equate
to A4:F40 because you specified each range as individual String values
separated by a comma... to have the Range evaluated as A4:A40 and F4:F40,
you need to write it as a **single** String value like this...

For Each R In Range("A4:A40,F4:F40")

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
I just wanted to say thank you...I have been stumped...I have needed the
code....

For Each R In Range("A4:A40")

The data is really in two columns.
Will it work if it is... For Each R In Range("A4:A40","F4:F40")?

"Rick Rothstein" wrote:

A44:A40 looks backwards for a range designation although Excel will
straighten it out to A40:A44). Anyway, you can try something like this...

For Each R In Range("A40:A44")

Using R (which should be declared as a Range variable) inside the loop to
reference each cell inside the range individually. You could also do this
(provided your cells are all in a single column)...

For X = 40 To 44

and use Cells(X, "A") to reference each individual cell in the range.

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
Thanks...that works perfectly! Now that I have it working for one cell
I
need to start working on making it loop for the Range("A44:A40").

"tompl" wrote:

Try this:
mynum = Worksheets("Sheet1").Range("A4").Value

Tom


"MovingBeyondtheRecordButton" wrote:

How do I change an existing code from...

mynum = Application.InputBox("Select Submission_ID")

...to mynum is located in cell A4 on sheet 1 (ie use the number
already
located in A4) with no InputBox

I've tried....
mynum = Worksheets("Sheet1").Cells(R4,C1)
mynum = Worksheets("Sheet1").Cells(4,1).Value
mynum = Range("A4")

I've even tried...
Range("A4").Select
mynum = ActiveCell

I just don't know how to tell it to input the number already
contained
in A4
as the input for the already existing code.

.

.

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
easy kyegibbon Excel Worksheet Functions 10 May 13th 06 09:20 AM
Easy one....Right? egeorge4 Excel Discussion (Misc queries) 4 May 12th 06 06:13 PM
How to sum in an easy way? [email protected] Excel Discussion (Misc queries) 7 April 20th 06 02:38 PM
Should Be Easy Mantis[_2_] Excel Programming 1 August 12th 05 05:31 PM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM


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