Consulting

Results 1 to 2 of 2

Thread: Fill first Empty cell in column When second column has an entry inserted

  1. #1
    VBAX Regular
    Joined
    Jul 2008
    Posts
    43
    Location

    Fill first Empty cell in column When second column has an entry inserted

    <div>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&nbsp; 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 count. I need to have the block find the first empty cell in column E when X moved to G and increase the number by one.<br><br>My existing block<br><br>If IsEmpty(Range("X4").Value) = False Then</div><div>&nbsp; &nbsp; &nbsp;Range("G2").Select</div><div>&nbsp; &nbsp; &nbsp;Selection.Insert Shift:=xlDown</div><div>&nbsp; &nbsp; &nbsp;Range("X4").Select</div><div>&nbsp; &nbsp; &nbsp;Selection.Cut</div><div>&nbsp; &nbsp; &nbsp;Range("G2").Select</div><div>&nbsp; &nbsp; &nbsp;ActiveSheet.Paste</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp;End If<br><br>I have used this formula below, before in&nbsp; another setting and it&nbsp; works fine on its own. However if I try to add it in, between activesheet.paste and End if&nbsp; &nbsp; &nbsp;I get an error on the last line.<br><br><div>&nbsp;Dim LastRow As Long</div><div>LastRow = ActiveSheet.Range("E" &amp; Rows.Count).End(xlUp).Row</div><div>ActiveSheet.Cells(LastRow + 1, "E").Value = ActiveSheet.Cells(LastRow, "E").Value + 1<br><br>I need it run in the same sub as the first block.<br>Any help is appreciated.</div></div><br>

  2. #2
    VBAX Regular
    Joined
    Jul 2008
    Posts
    43
    Location
    This thread moved to Excel. Posted here by mistake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •