kisinana
08-16-2021, 09:35 AM
I posted this by mistake to MS Project
Here is my problem, I hope I explain this well. I have a value that when my macro runs it looks to see if there is a value in cell X4 if there is, it moves the value to column G and inserts it in cell G2. This works fine, problem is though column E keeps track of all inserts and when this runs last item in Column G loses item number. I need to have the block find the first empty cell in column E when X moved to G and increase the number by onefrom the block above.
My existing block
If IsEmpty(Range("X4").Value) = False Then
Range("G2").Select
Selection.Insert Shift:=xlDown
Range("X4").Select
Selection.Cut
Range("G2").Select
ActiveSheet.Paste
End If
If IsEmpty(Range("X4").Value) = True Then
End If
I have used this formula below, before in another setting and it works fine on its own. However if I try to add it in, between activesheet.paste and End if. I get an error on the last line. I need it run in the same sub as the first block as at times program runs and there is no entry in X4. Any help is appreciated.
Sub Add1toColunm()
'
' Macro2 Macro
Dim LastRow As Long
LastRow = ActiveSheet.Range("E" & Rows.Count).End(xlUp).Row
ActiveSheet.Cells(LastRow + 1, "E").Value = ActiveSheet.Cells(LastRow, "E").Value + 1
'
End Sub
Thanks Kisinana
Here is my problem, I hope I explain this well. I have a value that when my macro runs it looks to see if there is a value in cell X4 if there is, it moves the value to column G and inserts it in cell G2. This works fine, problem is though column E keeps track of all inserts and when this runs last item in Column G loses item number. I need to have the block find the first empty cell in column E when X moved to G and increase the number by onefrom the block above.
My existing block
If IsEmpty(Range("X4").Value) = False Then
Range("G2").Select
Selection.Insert Shift:=xlDown
Range("X4").Select
Selection.Cut
Range("G2").Select
ActiveSheet.Paste
End If
If IsEmpty(Range("X4").Value) = True Then
End If
I have used this formula below, before in another setting and it works fine on its own. However if I try to add it in, between activesheet.paste and End if. I get an error on the last line. I need it run in the same sub as the first block as at times program runs and there is no entry in X4. Any help is appreciated.
Sub Add1toColunm()
'
' Macro2 Macro
Dim LastRow As Long
LastRow = ActiveSheet.Range("E" & Rows.Count).End(xlUp).Row
ActiveSheet.Cells(LastRow + 1, "E").Value = ActiveSheet.Cells(LastRow, "E").Value + 1
'
End Sub
Thanks Kisinana