Hello again
I am attempting to have a piece code enter a name in the first blank cell of the last column in use. For some reason the code I have keeps overwriting the previous cell. It also keeps adding the entries to the first column. The issue is this code needs to enter the data into the last column (what ever that may be), rather than the first column each time. I know the error I am making, I just don't know how to take it from Cells(Columns.Count, 1) to a variable which will change based on the most recently used column.
can anyone help with this?
Thanks all
I am attempting to have a piece code enter a name in the first blank cell of the last column in use. For some reason the code I have keeps overwriting the previous cell. It also keeps adding the entries to the first column. The issue is this code needs to enter the data into the last column (what ever that may be), rather than the first column each time. I know the error I am making, I just don't know how to take it from Cells(Columns.Count, 1) to a variable which will change based on the most recently used column.
can anyone help with this?
VBA Code:
Public Sub DetentionListAddName()
Application.ScreenUpdating = False
'Select Detentions list
Sheets("Detentions List").Select
'Select the first cell in column A
Range("A1").Select
'Copy Current Date Title
ActiveCell.Copy
'Find the last cell in column A that has data
Cells(Columns.Count, 1).End(xlUp).Offset(0, 2).Select
'Paste Title
Selection.PasteSpecial Paste:=xlPasteValues
'Select the sheet named "Submition Forms"
Sheets("Submition Forms").Select
'Select cell A4
Range("A4").Select
'Start the loop that will run until the active cell is empty
Do Until IsEmpty(ActiveCell)
'Select Cell to columns to the right
ActiveCell.Offset(0, 2).Select
'Check the value of the active cell
Select Case ActiveCell
Case "N"
'Copy the cell two columns to the left
ActiveCell.Offset(0, -2).Copy
'Go to the sheet named "Detentions List"
Sheets("Detentions List").Select
'Select the first cell in column A
Range("A1").Select
'Find the last cell in column A that has data
Cells(Columns.Count, 1).End(xlUp).Offset(0, 2).Select
'Select the next empty cell in column A
'ActiveCell.End(xlUp).Select
'ActiveCell.Offset(1, 0).Select
Cells(Columns.Count, 1).End(xlUp).Offset(1, 0).Select
'Paste the copied cell in the selected empty cell
Selection.PasteSpecial
'Go back to the sheet named "Submition Forms"
Sheets("Submition Forms").Select
Case "Y"
'If the value is "Y", do nothing
End Select
'Move to the next cell in column C
ActiveCell.Offset(1, -2).Select
Loop
Sheets("Detentions List").Select
Call FmtDetentions
Sheets("Submition Forms").Select
'select top cell
Range("A4").Select
'Reactivate screen updating
Application.ScreenUpdating = True
End Sub
Thanks all