View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_3_] Dick Kusleika[_3_] is offline
external usenet poster
 
Posts: 599
Default CODE to select range based on User Input or Value of Input Field

Sandi

You have some options. You can use an inputbox to get the week number like
this

Dim WeekNo As Variant

Do
WeekNo = Application.InputBox _
("Enter week number", , , , , , , 1)
If WeekNo = "False" Then
Exit Do
End If
Loop Until WeekNo = 1 And WeekNo <= 13

If WeekNo < "False" Then
Range("Week" & WeekNo).Copy _
Workbooks("Summary.xls").Sheets(1).Range("a1")
End If

This will loop until they enter a value from 1 to 13.

You can also use a userform with a listbox that lists all the weeks for the
user to select. Let me know if that's a better option for you and I'll walk
you through how to set it up.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.


"Sandi Gauthier" wrote in message
...
ok...first things first..i'm new to all of this...
i need help!...looking for some code that would export certain info to a

new
worksheet, based on USER INPUT...

my db is setup as so - i have a SOURCE WORKBOOK and a SUMMARY WORKBOOK...

SOURCE WORKBOOK
week / sales pro / revenue req'd / revenue achieved / account name

/
product ....
1 j. doe 1000.00 2000.00 abc
company widgets
2 j. doe 2000.00 1000.00 xyz
company hammers
3
4
5
to 13

i've NAMED each ROW to reflect the week (ie...Week1, Week2, Week3, Week4,
Week5, Week6, etc...to Week13)

SUMMARY WORKBOOK
i have some code (that i'm going to use from a previous project i worked

on)
that enables the user, at the click of a button to EXPORT the data range
that "I" defined into a new workbook...

now, however, i want the user to be able to export info for the WEEK
SPECIFIED BY THEM...for example export info for Week1 only onto new
workbook...

not quite sure how to go about this...

i've already NAMED the ranges so i was thinking perhaps of adding a

"prompt"
that would ask the user "Which Week Do You Want to Export?"...then perhaps
have a dropdown list (containing the names of my predefined weekly ranges
ie..Week1, Week2, etc..)

then i'd have to write code to say something like: if answer is Week1

then
Range(Week1).Select, if Week2 then Range(Week2).Select

i THINK i'm on the right track?

appreciate your assistance!
sandi