Finding first empty cell under a given cell range

OfficeUser

Well-known Member
Joined
Feb 4, 2010
Messages
544
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am currently using this code to plot out cell locations based on where I enter info into a cell. So for example if I put a letter into cell G25, then the corresponding grid coordinates would be D-3 and then that would be placed into the next empty cell under A33.

When I started using this code I never had info upto A57. After that all rows were hidden. I have since added more rows and now when I plot, my coordinates fall into the first empty cell of column A, cell A68. How do I get it go back to looking at the first empty cell under A33? Thanks.

Code:
Sub Plots(Target)
  Dim Grid As Range
  Dim Locus As String
  Dim NextCell As Range
  Dim R As Long, C As Long
    Set Target = Target.Cells(1, 1)
    Set Grid = Range("C20:AA28")
      If Not Intersect(Target, Grid) Is Nothing And Not IsError(Target.Value) Then
        If Target.Value <> "" Then
         Set NextCell = Cells(Rows.Count, "A").End(xlUp)
           If NextCell.Row < 33 Then Set NextCell = Range("A33")
         R = Target.Row
         C = Target.Column
        NextCell.Offset(1, 0) = Cells(R, "B") & "-" & Cells(29, C)
      End If
      End If
    Set Target = Target.Cells(1, 1)
    Set Grid = Range("AC20:BC28")
      If Not Intersect(Target, Grid) Is Nothing And Not IsError(Target.Value) Then
         If Target.Value <> "" Then
           Set NextCell = Cells(Rows.Count, "AD").End(xlUp)
           If NextCell.Row < 33 Then Set NextCell = Range("AD33")
         R = Target.Row
         C = Target.Column
         NextCell.Offset(1, 0) = Cells(R, "B") & "-" & Cells(29, C)
       End If
      End If
End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,224,586
Messages
6,179,707
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top