Hi!
I'm trying to create a UserForm which should ask for few info, than put the values (and some other values taken from the worksheet) into the sheet. for some reason only the first value is copied into the cell, afterwards the UserForm closes without any error message... I have no idea what ca be wrong... here is the code that runs when the "enter" button of the UserForm is pressed..
Any ideas?Private Sub EnterBt_Click() Dim emptyRow As Long Dim HeadingCounter As Integer Dim QuestionCounter_1 As Integer Sheets(1).Activate QuestionCounter_1 = Range("B2").Value HeadingCounter = Range("B1").Value emptyRow = WorksheetFunction.CountA(Range("a:a")) + 1 Cells(emptyRow, 2).Value = QuestionTBox.Value Cells(emptyRow, 3).Value = PageTBox.Value Cells(emptyRow, 4).Value = QuestionCounter_1 Cells(emptyRow, 5).Value = Chr(HeadingCounter) End Sub
Thanks!!!!
Mickey
Last edited by mickey001; 01-17-2012 at 10:51 AM.
Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
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 Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
thanks, fixed.
Try
Option Explicit Private Sub EnterBt_Click() Dim emptyRow As Long Dim HeadingCounter As Integer Dim QuestionCounter_1 As Integer With Sheets(1) QuestionCounter_1 = .Range("B2").Value HeadingCounter = .Range("B1").Value emptyRow = .Cells(.Rows.Count, 2).End(xlUp).Row + 1 .Cells(emptyRow, 2).Value = QuestionTBox.Value .Cells(emptyRow, 3).Value = PageTBox.Value .Cells(emptyRow, 4).Value = QuestionCounter_1 'not sure what this is .Cells(emptyRow, 5).Value = Chr(HeadingCounter) End With End Sub
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 Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
I think it works! thanks!!!
fyi:
B1 contains the value "65" in the beginning, which will be increased by 1 with the entry of each record, so with chr(HeadingCounter) I can assign letters A,B,C,... to each record... Is there any better way to do that?HeadingCounter = .Range("B1").Value
....
'not sure what this is
.Cells(emptyRow, 5).Value = Chr(HeadingCounter)
thanks again,
Mickey
Thanks for the rep. Your chr code should be fine until the number exceeds 26
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 Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks