cfree36 said:Firefytr:
Why the preference to sheet name or index number? What are the drawbacks to using the code name of a sheet in your code?
I have been using the code name so if the sheet is either moved, or renamed the VBA Code still works.
I am not questioning your thinking... just trying to learn from it.
Thanks.
cfree36 said:Sub PASTE()
Dim Name As String
Dim Sex As String
Name = Application.InputBox("What is your name?", "Enter Name Here")
Sheet2.Range("A1").Value = Name
Sex = Application.InputBox("Are you Male or Female?", "Enter Sex Here")
Sheet2.Range("A2").Value = Sex
End Sub
Change Sheet2 to the sheet number you want to paste your data and change the cells to where you want the data to go.
Note: Sheet2 is not the sheet's name, but rather it's sheet code
Sheet2 ("Main Doc")
Sheet2 is the code
Main Doc is the Sheet's Name
firefytr said:I'm curious how you 'created a dialog box'. Do you mean UserForm?
cfree36, I'm not saying that using a sheets code name is a bad thing, it's just not my personal preference. It can be difficult at times when dealing with code names from other workbooks and I find it to be more cumbersome. There really isn't anything wrong with what you posted, just not the way I do things.
There are many ways to skin a cat.