I could really use some help, I am doing a 20 hour exam for ICT and have slightly over estimated my problem solving abilities!
I really really need some help otherwise I will fail the course!
I am using the following Macro in a UserForm to enter data into a table. I have learnt the code to use in my exam but did not think what would happen if I were to move the table. I really need some help, and would appreciate someone explaining this to me.
Basically, I currently have a form at A1 to A3.Code:Sub CommandButton1_Click() Columns("A").End(xlDown).Select ActiveCell.Offset(1, 0).Value = firstname.Text ActiveCell.Offset(1, 1).Value = lastname.Text ActiveCell.Offset(1, 2).Value = gender.Text Unload AddData End Sub
eg:
A B C
1 First Name | Last Name | Gender
2 James | Scott | Male
As it is I can add data with a UserForm and it appears at the bottom of the table.
I need to be able to move the form so it is not in A1. I have tried changing A to C, D etc. and that worked so I know how to change the column location but I need help getting the data into the table that is on a different row.
I notice Columns("A") defines the Column for the text to be placed but how do I define Row?
Please please help!
Last edited by Leith Ross; 04-27-2009 at 01:47 PM. Reason: Added Code Tags
Try using Range where you can specify the row index and column index
Hello AugustRush,
Welcome to the Forum!
As a new member of the forum, please take a few minutes and read the forum rules for posting and general etiquette. To see them, click on the link below...
Forum Rules
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
If I were to name a table, would I be able to put the table name into the code so the text was entered into the table, wherever it was.
That would help a lot!
Please take note of what leith hs just posted!
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
Sorry, I misread (stress).
I will be more careful in the future.
Thanks
Please try to edit your title now
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
Your question isn't clear, where is the table to write to?
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks