PDA

View Full Version : Solved: Help with storing Sheet that Activates sequence to gather data from another sheet.



cjyogz
08-08-2006, 02:31 AM
Hello reader,

I have a sequence of code (below). When the user double clicks on a certain cell in Sheet("Income"), it initializes a UserForm(this code is not displayed below.) When the UserForm Initializes, it selects Sheet("Data") to collect information from cells contained in Rows A,B & C.

What i need help with, is i some how need to Store the Sheet("Income") as a Value of some sort so that after the code below has finished, it SetsFocus on Sheet("Income"). I also need it to SetFocus on the specific cell that the user double clicked. For example, A3, A4, A5, A6 and so on.

I would appreciate all the help i can get, even if you have a different way around my problem, then i am willing to try it.

Yours Great fully

Chris J


Private Sub UserForm_Initialize()
Sheets("Data").Select
Range("B2").Select
Do Until Selection.Value = False
cboExpense.AddItem (Selection.Value)
ActiveCell.Offset(1, 0).Select
Loop
Range("C2").Select
Do Until Selection.Value = False
cboIncome.AddItem (Selection.Value)
ActiveCell.Offset(1, 0).Select
Loop
Range("A2").Select
Do Until Selection.Value = False
cboSponsor.AddItem (Selection.Value)
ActiveCell.Offset(1, 0).Select
Loop

mdmackillop
08-08-2006, 05:06 AM
Try the following, adjusted as required, which should get the data without changing your selected sheet or cells

With Sheets("Data")
i = 0
Do
If .[B2].Offset(i) = False Then Exit Do
cboExpense.AddItem .[B2].Offset(i)
i = i + 1
Loop
End With

cjyogz
08-09-2006, 01:01 AM
This code works perfectly, exactly what i wanted it to dothanks mdmackillop.

mdmackillop
08-09-2006, 10:16 AM
Hi Chris.
Glad to help. If this is solved, please mark it so using Thread Tools.
Regards
MD