Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default need help in the code

in the below I am unable to get the for next loops to recall the inputs
stored in a String variable.

My below code works, but it takes the last value of the string and proceeds.
I want it to ask the same questions for all the stored string values.
Could you provide me the solution?

My code :

Dim groupamount
Dim groupname As String
Dim i As Long
Dim d As Long

' This section Gets Group Names

groupamount = InputBox("how many groups have you made?")
ActiveCell.Offset(4, 2).Insert
If groupamount < "" Then
For i = 1 To groupamount
groupname = InputBox("what is the name of your group " & i)
ActiveCell.Offset(i, 0).Value = groupname
Next i
d = groupamout - 1
End If

' This section captures Threats
Dim Threatnumber
Dim increase As Long
Dim threatname As String
Dim decrease As Long

Threatnumber = InputBox("How many threats do you foresee for " & groupname &
" group?")

If Threatnumber < "" Then
For increase = 1 To Threatnumber
threatname = InputBox("what is the name of your " & increase & "
threat?")
ActiveCell.Offset(8, 4).Insert
ActiveCell.Offset(increase, 4).Value = threatname
Next increase
End If
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default need help in the code

...like this ...?

Sub x()
Dim groupamount
Dim groupname As String
Dim i As Long
Dim d As Long
' This section captures Threats
Dim Threatnumber
Dim increase As Long
Dim threatname As String
Dim decrease As Long

' This section Gets Group Names

groupamount = InputBox("how many groups have you made?")
ActiveCell.Offset(4, 2).Insert
If groupamount < "" Then
For i = 1 To groupamount
groupname = InputBox("what is the name of your group " & i)
ActiveCell.Offset(i, 0).Value = groupname
Threatnumber = InputBox("How many threats do you foresee for " &
groupname & " group?")

If Threatnumber < "" Then
For increase = 1 To Threatnumber
threatname = InputBox("what is the name of your " & increase &
"threat?")
ActiveCell.Offset(8, 4).Insert
ActiveCell.Offset(increase, 4).Value = threatname
Next increase
End If
Next i
d = groupamout - 1
End If


HTH

"Deepak Varde" wrote:

in the below I am unable to get the for next loops to recall the inputs
stored in a String variable.

My below code works, but it takes the last value of the string and proceeds.
I want it to ask the same questions for all the stored string values.
Could you provide me the solution?

My code :

Dim groupamount
Dim groupname As String
Dim i As Long
Dim d As Long

' This section Gets Group Names

groupamount = InputBox("how many groups have you made?")
ActiveCell.Offset(4, 2).Insert
If groupamount < "" Then
For i = 1 To groupamount
groupname = InputBox("what is the name of your group " & i)
ActiveCell.Offset(i, 0).Value = groupname
Next i
d = groupamout - 1
End If

' This section captures Threats
Dim Threatnumber
Dim increase As Long
Dim threatname As String
Dim decrease As Long

Threatnumber = InputBox("How many threats do you foresee for " & groupname &
" group?")

If Threatnumber < "" Then
For increase = 1 To Threatnumber
threatname = InputBox("what is the name of your " & increase & "
threat?")
ActiveCell.Offset(8, 4).Insert
ActiveCell.Offset(increase, 4).Value = threatname
Next increase
End If

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default need help in the code

if I have a string variable to capture user inputs to the extent of numbers
he has provided, I want to be able to ask as many questions as equal to the
number he has specified.
e.g
If the question is how many groups you have made
he answers 2
then my questions are : what is the name of your first group & then
what is the name of your 2 group?
the inputs of these questions as stored in som cell

both the inputs refer to a string called groupaname.

Now if I want to ask a question what is the value of your 1st group and so on
my code below just does it for the last variable stored.
I want it to be able to look at earlier stored values too.




"Toppers" wrote:

..like this ...?

Sub x()
Dim groupamount
Dim groupname As String
Dim i As Long
Dim d As Long
' This section captures Threats
Dim Threatnumber
Dim increase As Long
Dim threatname As String
Dim decrease As Long

' This section Gets Group Names

groupamount = InputBox("how many groups have you made?")
ActiveCell.Offset(4, 2).Insert
If groupamount < "" Then
For i = 1 To groupamount
groupname = InputBox("what is the name of your group " & i)
ActiveCell.Offset(i, 0).Value = groupname
Threatnumber = InputBox("How many threats do you foresee for " &
groupname & " group?")

If Threatnumber < "" Then
For increase = 1 To Threatnumber
threatname = InputBox("what is the name of your " & increase &
"threat?")
ActiveCell.Offset(8, 4).Insert
ActiveCell.Offset(increase, 4).Value = threatname
Next increase
End If
Next i
d = groupamout - 1
End If


HTH

"Deepak Varde" wrote:

in the below I am unable to get the for next loops to recall the inputs
stored in a String variable.

My below code works, but it takes the last value of the string and proceeds.
I want it to ask the same questions for all the stored string values.
Could you provide me the solution?

My code :

Dim groupamount
Dim groupname As String
Dim i As Long
Dim d As Long

' This section Gets Group Names

groupamount = InputBox("how many groups have you made?")
ActiveCell.Offset(4, 2).Insert
If groupamount < "" Then
For i = 1 To groupamount
groupname = InputBox("what is the name of your group " & i)
ActiveCell.Offset(i, 0).Value = groupname
Next i
d = groupamout - 1
End If

' This section captures Threats
Dim Threatnumber
Dim increase As Long
Dim threatname As String
Dim decrease As Long

Threatnumber = InputBox("How many threats do you foresee for " & groupname &
" group?")

If Threatnumber < "" Then
For increase = 1 To Threatnumber
threatname = InputBox("what is the name of your " & increase & "
threat?")
ActiveCell.Offset(8, 4).Insert
ActiveCell.Offset(increase, 4).Value = threatname
Next increase
End If

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
code not unique find latest date Barbara Wiseman Excel Discussion (Misc queries) 3 December 11th 05 08:50 AM
VLOOKUP for Zip Code Ranges JerseyJR Excel Worksheet Functions 2 September 6th 05 06:37 PM
Conform a total to a list of results? xmaveric Excel Discussion (Misc queries) 1 August 21st 05 07:22 PM
Macro for changing text to Proper Case JPriest Excel Worksheet Functions 3 August 8th 05 09:31 PM
close form code tkaplan Excel Discussion (Misc queries) 1 June 3rd 05 10:49 PM


All times are GMT +1. The time now is 01:28 AM.

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"