Run macro until range ends

W

wagz

Here is the short of the long....

I have an web app that I am trying to input data from an excel sheet. This
excel sheet also acts as a database, so it not only will give me my new info
but keeps that info for future reference.

Is there a way to have a userform as part of the macro that would ask the
user to input the row that they want to start the data import from and in
that same form ask for an end row. With hopes that the result of all of this
would be a macro that would perform its duty only in range that you have
provisioned.

The macro that will be running is going to be moving between the excel sheet
and the web app to copy and paste its data with multiple send keys being used.

I am using excel 2007 and intermediate with VBA and a novice with userforms.

Thanks for all the help in advance!
-Wagz
 
J

Joel

Set FirstCell = Application.InputBox( _
prompt:="Select First cell", Type:=8)
Set Lastcell = Application.InputBox( _
prompt:="Select Last cell", Type:=8)
Set MyRange = Range(FirstCell, Lastcell)
For Each cell In MyRange

'enter your code here

Next cell
 
W

wagz

Joel-

One of the things that I failed to mention is that the row would 10 cells of
data (6 that would actually be used. I imagine that this changes the
programming?

Sorry-
Eric
 
J

Joel

Try something like this


Set FirstCell = Application.InputBox( _
prompt:="Select First cell", Type:=8)
Set Lastcell = Application.InputBox( _
prompt:="Select Last cell", Type:=8)
Set MyRange = Range(FirstCell, Lastcell)

count = 0
For Each cell In MyRange

'enter your code here
count = count + 1
if count = 6 then exit for

Next cell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top