All I know about VBA in Excel is what I have cannablized from other people's xls files.
So a lot of the commands throw me on how exactly I am supposed to implement them. I
just discovered macros in the modules about two days ago. So if you can help me, talk
to me like I am a child :P
this is what I have always used to put data from my userform into my spreadsheet:
Code:
Private Sub TextBox1_Change()
Range("A1").Value = Me.TextBox1.Value
End Sub
Now I need more advanced code. Here is what i have:
I have one userform i want to use for everything I need. It has a calendar that I
click to choose the date I will be working with. I have seven buttons that match 7
worksheets set up with exactly the same cell structure and labeling, the only difference
is the name of the worksheet is the catagory that data needs to be in, hence the 7
worksheets.
Here is what I need:
click the date I need the proper row to recieve information from the textboxes
boxes in my userform and the row it needs to go in should be assigned o the textboxes.
Each textbox should put data into it's assigned column no matter which sheet or row I am
on, but the column the data from the textbox goes into is decided by the date I clicked.
With a possible range of 1-31 for the days of the month.
Now when i click one of my seven commandbuttons I need the information to go to the
correct sheet.
So simplisticly I needthe code in my userform to take what is entered into it and input
that data into my spreadsheet with these settings:
CommandButton_Click goes to sheet needed
TextBox goes to the column needed
Date's day selected (1-31) goes to rown needed.
I think I have a solution to the first problem. Its pretty simplistic and isn't as nice
as it all happening behind the scenes.
Code:
Private Sub CommandButton1_Click()
Worksheets("Exams").Activate
End Sub
That will at least make the sheet I need the info to into active. I just make each of
the 7 buttons load the needed page.
I am just not learned enough yet to take it further than that solution. Of course I am
open to a more streamlined solution.
The second part of code I need help with really has me stumped. I have been reading a
lot of tutorials and I am
wondering if something like this would help:
Code:
Dim MyDate, MyDay
MyDate = Worksheets("Calc").Range("B1").Value
MyDay = Day(MyDate)
("Calc").Range("B1") is where my calander inserts the date when clicked. If this little
code breaks it down to a simple
number bewteen 1 and 31 then I just need to understand how to insert it into a macro
that targets the correct cell.
I have been using
Code:
Private Sub TextBox1_Change()
Range("A1").Value = Me.TextBox1.Value
End Sub
but to continue to do that would take 31 userforms. So I need to figure out how to
replace "A1" with something like
Code:
Private Sub TextBox1_Change()
Range("A.MyDay").Value = Me.TextBox1.Value
End Sub
but I have yet to find anything like that in examples I have been pouring
over. I know that isn't real code,
but its the only way I can think to explain it.
On a side note do I need to be doing something with the LabelRange Dialogue box on the
spreadsheet side of this to get what I want to work?
Thanks!