A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
I am having a few hiccups with the excel the workbook.
If I try and enter any information into the cells, I get a Run-time error '13': Type mismach. The Debug shows
'Get the selected number of employees again. g_EmployeeNumber = CInt(Target.Value)
as highlighted.
Also, when I try to add more cells to reach the desired limit of 50, I get an error asking me to delete the last column and row of cells to prevent the loss of date.
Thanks for the help thus-far. Thought this thread was D.O.A. lol
OK~
I'm sorry for that error.
Changed code to refer:
Private Sub Worksheet_Change(ByVal Target As Range)
'/* If user changes the number of employees. */
If Target.Address = strCellAddressOfEmployeeNumber Then
Dim intCountEmployee As Integer
'Get the current selected number of employees.
intCountEmployee = CInt(Target.Value)
'/* If the current selected number of employees is not the same as before selecting. */
If intCountEmployee <> CInt(g_EmployeeNumber) Then
Dim dblRows As Double
'Count rows which contained numbers in the ID column.
dblRows = WorksheetFunction.Count(Range("A:A"))
Dim lngHiddenFrom As Long
Dim lngHiddenTo As Long
'/* To obtain the range of hidden rows. */
lngHiddenFrom = intCountEmployee + 6 + 1
lngHiddenTo = dblRows + 6
'Disable screen updating while hiding.
Application.ScreenUpdating = False
'Force to show all hidden rows.
Rows("1" & ":" & CStr(lngHiddenTo)).Hidden = False
'/* If the current selected number of employees is smaller than the total number of employees. */
If intCountEmployee < dblRows Then
Rows(CStr(lngHiddenFrom) & ":" & CStr(lngHiddenTo)).Hidden = True
End If
'Enable screen updating after hiding.
Application.ScreenUpdating = True
End If
'Get the selected number of employees again.
g_EmployeeNumber = Target.Value
End If
End Sub
For your second question:
Excel will prevent data adding when there are too many merged areas and the amount of cells is varied in each area, or there might be characters such as spaces across the rows or columns.
My approach is to let all hidden rows and columns displayed, and then cancel the merged range from address "A27:I27" to the end, so that you can add data!
Here a new document has been updated, please link to this page:
If you have any other questions, welcome to tell me.