10shlomi10
12-20-2016, 02:10 AM
Good Morning ,
Have a strange thing....
Maybe it a silly thing but I couldn't figure out what cause excel to crash (meaning, close and reopened) .
when I press the button on UserForm to pass the data from UserForm Controls to worksheet, excel crash:(
I see that he crashes when he arrived to a rather simple line of code which is to transfer the TextBox text, from UserForm (called UpdateIndex), into the sheet on last empty row.
for some unknown reason excel then crash.
'To find LastRow I'm using the line:
LastRow = WorksheetFunction.CountA(Sheets("AccIndex").Range("A:A"))
'Last Empty Row:
LastEmptyRow = LastRow + 1
If UpdateIndex.TextBox1 = vbNullString Then Exit Sub
Sheets("AccIndex").Cells(LastEmptyRow, 1) = CStr(UpdateIndex.TextBox1)
If UpdateIndex.TextBox2 = vbNullString Then Exit Sub
Sheets("AccIndex").Cells(LastEmptyRow, 2) = CStr(UpdateIndex.TextBox2)
If UpdateIndex.ComboBox1 = vbNullString Then GoTo MyMsg
Sheets("AccIndex").Cells(LastEmptyRow, 3) = CStr(UpdateIndex.ComboBox1)
There are more ComboBoxes (10 of those) but it's keep the same principal as show above.
The more un-logic thing is when I pass the data to LastRow it work prefect. :wot
of course, no can do as it rewrite on data I already have in that cell.
The Data on sheet is TABLE (not regular range, so , hopefully , it will resize in every new row.
I've tried the above on regular range as well, and it acts same, i.e: crashes:banghead:
Run it now and it gives me the following error:
1787517876
as the file contain some other UserForms and code I can not load it to forum.
(I can send it in private)
Can please someone help me with that ?:(
All The Best !
Have a strange thing....
Maybe it a silly thing but I couldn't figure out what cause excel to crash (meaning, close and reopened) .
when I press the button on UserForm to pass the data from UserForm Controls to worksheet, excel crash:(
I see that he crashes when he arrived to a rather simple line of code which is to transfer the TextBox text, from UserForm (called UpdateIndex), into the sheet on last empty row.
for some unknown reason excel then crash.
'To find LastRow I'm using the line:
LastRow = WorksheetFunction.CountA(Sheets("AccIndex").Range("A:A"))
'Last Empty Row:
LastEmptyRow = LastRow + 1
If UpdateIndex.TextBox1 = vbNullString Then Exit Sub
Sheets("AccIndex").Cells(LastEmptyRow, 1) = CStr(UpdateIndex.TextBox1)
If UpdateIndex.TextBox2 = vbNullString Then Exit Sub
Sheets("AccIndex").Cells(LastEmptyRow, 2) = CStr(UpdateIndex.TextBox2)
If UpdateIndex.ComboBox1 = vbNullString Then GoTo MyMsg
Sheets("AccIndex").Cells(LastEmptyRow, 3) = CStr(UpdateIndex.ComboBox1)
There are more ComboBoxes (10 of those) but it's keep the same principal as show above.
The more un-logic thing is when I pass the data to LastRow it work prefect. :wot
of course, no can do as it rewrite on data I already have in that cell.
The Data on sheet is TABLE (not regular range, so , hopefully , it will resize in every new row.
I've tried the above on regular range as well, and it acts same, i.e: crashes:banghead:
Run it now and it gives me the following error:
1787517876
as the file contain some other UserForms and code I can not load it to forum.
(I can send it in private)
Can please someone help me with that ?:(
All The Best !