Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Problem in Excel...String of Ranges?

Is it possible to have a user select multiple cells associated with a
sample? My vba is below, but it keeps giving me an error on having the
InputBox = type 8 (range). Is this not possible? I figured it would
be fine to have the layout like this...but if someone knows of a better
way that would work it would be fine.

Sub Cmpds()

Dim Compounds() As String
Dim numCompounds As Long
Dim cnt As Long
numCompounds = InputBox("Enter the Number of Compounds")
ReDim Compounds(1 To numCompounds)
For cnt = 1 To numCompounds
Compounds(cnt) = InputBox("Please Enter Compound " & cnt)
Next

Dim CmpdRng() As String
Dim count As Long
ReDim CmpdRng(1 To numCompounds)
For count = 1 To numCompounds
CmpdRng(cnt) = InputBox("Please Select Data for Compound " &
count, Type:=8)
Next

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Problem in Excel...String of Ranges?

Try:
Dim numCompounds As Long
Dim cnt As Long
Dim CmpdRng() As Range
Dim count As Long

numCompounds = InputBox("Enter the Number of Compounds")

ReDim CmpdRng(numCompounds)
For count = 1 To numCompounds
Set CmpdRng(count) = Application.InputBox(prompt:="Please Select Data
for Compound ", Type:=8)
Next


" wrote:

Is it possible to have a user select multiple cells associated with a
sample? My vba is below, but it keeps giving me an error on having the
InputBox = type 8 (range). Is this not possible? I figured it would
be fine to have the layout like this...but if someone knows of a better
way that would work it would be fine.

Sub Cmpds()

Dim Compounds() As String
Dim numCompounds As Long
Dim cnt As Long
numCompounds = InputBox("Enter the Number of Compounds")
ReDim Compounds(1 To numCompounds)
For cnt = 1 To numCompounds
Compounds(cnt) = InputBox("Please Enter Compound " & cnt)
Next

Dim CmpdRng() As String
Dim count As Long
ReDim CmpdRng(1 To numCompounds)
For count = 1 To numCompounds
CmpdRng(cnt) = InputBox("Please Select Data for Compound " &
count, Type:=8)
Next

End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Problem in Excel...String of Ranges?

Charles,

Again, thanks, you have been a lifesaver here...I figured that out a
little bit ago, but it still it not liking the rest of my code, like it
doesn't want to loop through the compounds to select more data. I am
not sure if it's my code (most likely) but it should be able to store
multiple ranges of cells right?
Die_Another_Day wrote:
Stephen, if you want to specify the type of entry in a InputBox then
you have to use Application.InputBox instead of just inputbox. See this
article from Joseph Rubin's Site:
http://www.exceltip.com/st/Decide_wh...Excel/408.html

Charles

wrote:
Is it possible to have a user select multiple cells associated with a
sample? My vba is below, but it keeps giving me an error on having the
InputBox = type 8 (range). Is this not possible? I figured it would
be fine to have the layout like this...but if someone knows of a better
way that would work it would be fine.

Sub Cmpds()

Dim Compounds() As String
Dim numCompounds As Long
Dim cnt As Long
numCompounds = InputBox("Enter the Number of Compounds")
ReDim Compounds(1 To numCompounds)
For cnt = 1 To numCompounds
Compounds(cnt) = InputBox("Please Enter Compound " & cnt)
Next

Dim CmpdRng() As String
Dim count As Long
ReDim CmpdRng(1 To numCompounds)
For count = 1 To numCompounds
CmpdRng(cnt) = InputBox("Please Select Data for Compound " &
count, Type:=8)
Next

End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Problem in Excel...String of Ranges?

Stefen,

Use this modified macro :

Sub Cmpds()
Dim Compounds() As String
Dim numCompounds As Long
Dim cnt As Long
numCompounds = InputBox("Enter the Number of Compounds")
ReDim Compounds(1 To numCompounds)
For cnt = 1 To numCompounds
Compounds(cnt) = InputBox("Please Enter Compound " & cnt)
Next
Dim rTempRange As Range
Dim sCmpdRng() As String
Dim count As Long
ReDim sCmpdRng(1 To numCompounds)
For count = 1 To numCompounds
Set rTempRange = Application.InputBox("Please Select Data for
Compound " & count, Type:=8)
sCmpdRng(count) = rTempRange.Address
Next
End Sub

" wrote:

Is it possible to have a user select multiple cells associated with a
sample? My vba is below, but it keeps giving me an error on having the
InputBox = type 8 (range). Is this not possible? I figured it would
be fine to have the layout like this...but if someone knows of a better
way that would work it would be fine.

Sub Cmpds()

Dim Compounds() As String
Dim numCompounds As Long
Dim cnt As Long
numCompounds = InputBox("Enter the Number of Compounds")
ReDim Compounds(1 To numCompounds)
For cnt = 1 To numCompounds
Compounds(cnt) = InputBox("Please Enter Compound " & cnt)
Next

Dim CmpdRng() As String
Dim count As Long
ReDim CmpdRng(1 To numCompounds)
For count = 1 To numCompounds
CmpdRng(cnt) = InputBox("Please Select Data for Compound " &
count, Type:=8)
Next

End Sub




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Problem in Excel...String of Ranges?

I have gotten it to where it will let me select the cells, but then it
tells me "Object variable or With block variable not set". I don't
know why I would need to have a with block here, it seems as though the
way the macro is written it should be fine as is.
ccroche wrote:
Stefen,

Use this modified macro :

Sub Cmpds()
Dim Compounds() As String
Dim numCompounds As Long
Dim cnt As Long
numCompounds = InputBox("Enter the Number of Compounds")
ReDim Compounds(1 To numCompounds)
For cnt = 1 To numCompounds
Compounds(cnt) = InputBox("Please Enter Compound " & cnt)
Next
Dim rTempRange As Range
Dim sCmpdRng() As String
Dim count As Long
ReDim sCmpdRng(1 To numCompounds)
For count = 1 To numCompounds
Set rTempRange = Application.InputBox("Please Select Data for
Compound " & count, Type:=8)
sCmpdRng(count) = rTempRange.Address
Next
End Sub

" wrote:

Is it possible to have a user select multiple cells associated with a
sample? My vba is below, but it keeps giving me an error on having the
InputBox = type 8 (range). Is this not possible? I figured it would
be fine to have the layout like this...but if someone knows of a better
way that would work it would be fine.

Sub Cmpds()

Dim Compounds() As String
Dim numCompounds As Long
Dim cnt As Long
numCompounds = InputBox("Enter the Number of Compounds")
ReDim Compounds(1 To numCompounds)
For cnt = 1 To numCompounds
Compounds(cnt) = InputBox("Please Enter Compound " & cnt)
Next

Dim CmpdRng() As String
Dim count As Long
ReDim CmpdRng(1 To numCompounds)
For count = 1 To numCompounds
CmpdRng(cnt) = InputBox("Please Select Data for Compound " &
count, Type:=8)
Next

End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Problem in Excel...String of Ranges?

code posted by ccroche worked fine for me as long as I selected a range.
What is your problem?

--
Regards,
Tom Ogilvy

wrote in message
oups.com...
I have gotten it to where it will let me select the cells, but then it
tells me "Object variable or With block variable not set". I don't
know why I would need to have a with block here, it seems as though the
way the macro is written it should be fine as is.
ccroche wrote:
Stefen,

Use this modified macro :

Sub Cmpds()
Dim Compounds() As String
Dim numCompounds As Long
Dim cnt As Long
numCompounds = InputBox("Enter the Number of Compounds")
ReDim Compounds(1 To numCompounds)
For cnt = 1 To numCompounds
Compounds(cnt) = InputBox("Please Enter Compound " & cnt)
Next
Dim rTempRange As Range
Dim sCmpdRng() As String
Dim count As Long
ReDim sCmpdRng(1 To numCompounds)
For count = 1 To numCompounds
Set rTempRange = Application.InputBox("Please Select Data for
Compound " & count, Type:=8)
sCmpdRng(count) = rTempRange.Address
Next
End Sub

" wrote:

Is it possible to have a user select multiple cells associated with a
sample? My vba is below, but it keeps giving me an error on having the
InputBox = type 8 (range). Is this not possible? I figured it would
be fine to have the layout like this...but if someone knows of a better
way that would work it would be fine.

Sub Cmpds()

Dim Compounds() As String
Dim numCompounds As Long
Dim cnt As Long
numCompounds = InputBox("Enter the Number of Compounds")
ReDim Compounds(1 To numCompounds)
For cnt = 1 To numCompounds
Compounds(cnt) = InputBox("Please Enter Compound " & cnt)
Next

Dim CmpdRng() As String
Dim count As Long
ReDim CmpdRng(1 To numCompounds)
For count = 1 To numCompounds
CmpdRng(cnt) = InputBox("Please Select Data for Compound " &
count, Type:=8)
Next

End Sub





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
Delete named ranges beginning with a string GoFigure[_7_] Excel Programming 2 December 4th 05 12:23 PM
String problem. Mannyluk Excel Programming 1 October 16th 04 08:43 PM
Excel VBA - String concatanation problem RyanVM Excel Programming 4 August 3rd 04 05:58 PM
string problem pwz Excel Programming 2 June 20th 04 06:11 PM
SQL string problem TLowe Excel Programming 15 June 11th 04 10:56 AM


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