#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Macro in excel/ced

I have a macro in Microsoft Excel listed below. I need for it to repeat
until xxx is entered. Any help will be appreciated.



Sub OptionExplicit()
'
' OptionExplicit Macro
' Macro recorded 3/10/2008 by Student Financial Aid
'
Dim vName As String
Dim vAddress As String
Dim vCityStateZip As String
Dim vPhoneNumber As String
Dim vEmailAddress As String
Dim vRealEstateAgentAndCompany As String
Dim vxxx As String

vName = InputBox("Please type in your name?")
If vName = "xxx" Then
Exit Sub
Else
vAddress = InputBox("Please enter your address?")
vCityStateZip = InputBox("Please enter City, State and Zip?")
vPhoneNumber = InputBox("Please enter your Phone Number?")
vEmailAddress = InputBox("Please enter your Email Address?")
vRealEstateAgentAndCompany = InputBox("Please enter your Real Estate Agent
and Company?")
Worksheets("Sheet1").Range("B1") = vName
Worksheets("Sheet1").Range("B2") = vAddress
Worksheets("Sheet1").Range("B3") = vCityStateZip
Worksheets("Sheet1").Range("B4") = vPhoneNumber
Worksheets("Sheet1").Range("B5") = vEmailAddress
Worksheets("Sheet1").Range("B6") = vRealEstateAgentAndCompany

'
Range("B1").Select
Range("B2").Select
Range("B3").Select
Range("B4").Select
Range("B5").Select
Range("B6").Select


vName = InputBox("Please type in your name?")
vAddress = InputBox("Please enter your address?")
vCityStateZip = InputBox("Please enter City, State and Zip?")
vPhoneNumber = InputBox("Please enter your Phone Number?")
vEmailAddress = InputBox("Please enter your Email Address?")
vRealEstateAgentAndCompany = InputBox("Please enter your Real Estate Agent
and Company?")
Worksheets("Sheet1").Range("B11") = vName
Worksheets("Sheet1").Range("B12") = vAddress
Worksheets("Sheet1").Range("B13") = vCityStateZip
Worksheets("Sheet1").Range("B14") = vPhoneNumber
Worksheets("Sheet1").Range("B15") = vEmailAddress
Worksheets("Sheet1").Range("B16") = vRealEstateAgentAndCompany

'
Range("B11").Select
Range("B12").Select
Range("B13").Select
Range("B14").Select
Range("B15").Select
Range("B16").Select



End If
Application.Goto Reference:="OptionExplicit"
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Macro in excel/ced

Right before the InputBox statement, put:
DO

and at the end of the code you want repeated, put:
LOOP
--
Gary''s Student - gsnu2007f


"Cedric" wrote:

I have a macro in Microsoft Excel listed below. I need for it to repeat
until xxx is entered. Any help will be appreciated.



Sub OptionExplicit()
'
' OptionExplicit Macro
' Macro recorded 3/10/2008 by Student Financial Aid
'
Dim vName As String
Dim vAddress As String
Dim vCityStateZip As String
Dim vPhoneNumber As String
Dim vEmailAddress As String
Dim vRealEstateAgentAndCompany As String
Dim vxxx As String

vName = InputBox("Please type in your name?")
If vName = "xxx" Then
Exit Sub
Else
vAddress = InputBox("Please enter your address?")
vCityStateZip = InputBox("Please enter City, State and Zip?")
vPhoneNumber = InputBox("Please enter your Phone Number?")
vEmailAddress = InputBox("Please enter your Email Address?")
vRealEstateAgentAndCompany = InputBox("Please enter your Real Estate Agent
and Company?")
Worksheets("Sheet1").Range("B1") = vName
Worksheets("Sheet1").Range("B2") = vAddress
Worksheets("Sheet1").Range("B3") = vCityStateZip
Worksheets("Sheet1").Range("B4") = vPhoneNumber
Worksheets("Sheet1").Range("B5") = vEmailAddress
Worksheets("Sheet1").Range("B6") = vRealEstateAgentAndCompany

'
Range("B1").Select
Range("B2").Select
Range("B3").Select
Range("B4").Select
Range("B5").Select
Range("B6").Select


vName = InputBox("Please type in your name?")
vAddress = InputBox("Please enter your address?")
vCityStateZip = InputBox("Please enter City, State and Zip?")
vPhoneNumber = InputBox("Please enter your Phone Number?")
vEmailAddress = InputBox("Please enter your Email Address?")
vRealEstateAgentAndCompany = InputBox("Please enter your Real Estate Agent
and Company?")
Worksheets("Sheet1").Range("B11") = vName
Worksheets("Sheet1").Range("B12") = vAddress
Worksheets("Sheet1").Range("B13") = vCityStateZip
Worksheets("Sheet1").Range("B14") = vPhoneNumber
Worksheets("Sheet1").Range("B15") = vEmailAddress
Worksheets("Sheet1").Range("B16") = vRealEstateAgentAndCompany

'
Range("B11").Select
Range("B12").Select
Range("B13").Select
Range("B14").Select
Range("B15").Select
Range("B16").Select



End If
Application.Goto Reference:="OptionExplicit"
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Macro in excel/ced

hi
what are you trying to do with this code. if you put this code in a loop,
you will be over writing the same locations over and over again + get caught
in an endless loop.

regards
FSt1

"Cedric" wrote:

I have a macro in Microsoft Excel listed below. I need for it to repeat
until xxx is entered. Any help will be appreciated.



Sub OptionExplicit()
'
' OptionExplicit Macro
' Macro recorded 3/10/2008 by Student Financial Aid
'
Dim vName As String
Dim vAddress As String
Dim vCityStateZip As String
Dim vPhoneNumber As String
Dim vEmailAddress As String
Dim vRealEstateAgentAndCompany As String
Dim vxxx As String

vName = InputBox("Please type in your name?")
If vName = "xxx" Then
Exit Sub
Else
vAddress = InputBox("Please enter your address?")
vCityStateZip = InputBox("Please enter City, State and Zip?")
vPhoneNumber = InputBox("Please enter your Phone Number?")
vEmailAddress = InputBox("Please enter your Email Address?")
vRealEstateAgentAndCompany = InputBox("Please enter your Real Estate Agent
and Company?")
Worksheets("Sheet1").Range("B1") = vName
Worksheets("Sheet1").Range("B2") = vAddress
Worksheets("Sheet1").Range("B3") = vCityStateZip
Worksheets("Sheet1").Range("B4") = vPhoneNumber
Worksheets("Sheet1").Range("B5") = vEmailAddress
Worksheets("Sheet1").Range("B6") = vRealEstateAgentAndCompany

'
Range("B1").Select
Range("B2").Select
Range("B3").Select
Range("B4").Select
Range("B5").Select
Range("B6").Select


vName = InputBox("Please type in your name?")
vAddress = InputBox("Please enter your address?")
vCityStateZip = InputBox("Please enter City, State and Zip?")
vPhoneNumber = InputBox("Please enter your Phone Number?")
vEmailAddress = InputBox("Please enter your Email Address?")
vRealEstateAgentAndCompany = InputBox("Please enter your Real Estate Agent
and Company?")
Worksheets("Sheet1").Range("B11") = vName
Worksheets("Sheet1").Range("B12") = vAddress
Worksheets("Sheet1").Range("B13") = vCityStateZip
Worksheets("Sheet1").Range("B14") = vPhoneNumber
Worksheets("Sheet1").Range("B15") = vEmailAddress
Worksheets("Sheet1").Range("B16") = vRealEstateAgentAndCompany

'
Range("B11").Select
Range("B12").Select
Range("B13").Select
Range("B14").Select
Range("B15").Select
Range("B16").Select



End If
Application.Goto Reference:="OptionExplicit"
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Macro in excel/ced

I am trying to have excel prompt me to enter a name, address,etc. I want it
to repeat the same questions until I enter xxx. I know I have to change the
location each time I enter a different name. I just cannot get it to exit
after I enter xxx.

Thanks



"FSt1" wrote:

hi
what are you trying to do with this code. if you put this code in a loop,
you will be over writing the same locations over and over again + get caught
in an endless loop.

regards
FSt1

"Cedric" wrote:

I have a macro in Microsoft Excel listed below. I need for it to repeat
until xxx is entered. Any help will be appreciated.



Sub OptionExplicit()
'
' OptionExplicit Macro
' Macro recorded 3/10/2008 by Student Financial Aid
'
Dim vName As String
Dim vAddress As String
Dim vCityStateZip As String
Dim vPhoneNumber As String
Dim vEmailAddress As String
Dim vRealEstateAgentAndCompany As String
Dim vxxx As String

vName = InputBox("Please type in your name?")
If vName = "xxx" Then
Exit Sub
Else
vAddress = InputBox("Please enter your address?")
vCityStateZip = InputBox("Please enter City, State and Zip?")
vPhoneNumber = InputBox("Please enter your Phone Number?")
vEmailAddress = InputBox("Please enter your Email Address?")
vRealEstateAgentAndCompany = InputBox("Please enter your Real Estate Agent
and Company?")
Worksheets("Sheet1").Range("B1") = vName
Worksheets("Sheet1").Range("B2") = vAddress
Worksheets("Sheet1").Range("B3") = vCityStateZip
Worksheets("Sheet1").Range("B4") = vPhoneNumber
Worksheets("Sheet1").Range("B5") = vEmailAddress
Worksheets("Sheet1").Range("B6") = vRealEstateAgentAndCompany

'
Range("B1").Select
Range("B2").Select
Range("B3").Select
Range("B4").Select
Range("B5").Select
Range("B6").Select


vName = InputBox("Please type in your name?")
vAddress = InputBox("Please enter your address?")
vCityStateZip = InputBox("Please enter City, State and Zip?")
vPhoneNumber = InputBox("Please enter your Phone Number?")
vEmailAddress = InputBox("Please enter your Email Address?")
vRealEstateAgentAndCompany = InputBox("Please enter your Real Estate Agent
and Company?")
Worksheets("Sheet1").Range("B11") = vName
Worksheets("Sheet1").Range("B12") = vAddress
Worksheets("Sheet1").Range("B13") = vCityStateZip
Worksheets("Sheet1").Range("B14") = vPhoneNumber
Worksheets("Sheet1").Range("B15") = vEmailAddress
Worksheets("Sheet1").Range("B16") = vRealEstateAgentAndCompany

'
Range("B11").Select
Range("B12").Select
Range("B13").Select
Range("B14").Select
Range("B15").Select
Range("B16").Select



End If
Application.Goto Reference:="OptionExplicit"
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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
passing arguments from an excel macro to a word macro KWE39 Excel Discussion (Misc queries) 1 July 7th 05 03:56 PM
Macro - Open Word with Excel macro Bill Excel Discussion (Misc queries) 3 May 23rd 05 11:21 PM


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