# Find Next Empty Cell

#### temerson

##### New Member
Hello,

I have the following code:

Sub EmptyRow()

On Error Resume Next

Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Application.ScreenUpdating = False

Dim wbCurrent As Workbook
Dim wsCHINO As Worksheet
Dim wsSTOCKTON As Worksheet
Dim wsFLM As Worksheet
Dim wsDGV As Worksheet
Dim wsAURORA As Worksheet

Dim nLastCol, i As Integer

'KEEP CHINO COLUMNS
Set wbCurrent = ActiveWorkbook
Set wsCHINO = wbCurrent.Worksheets("CHINO")

nLastCol = wsCHINO.Cells.Find("*", LookIn:=xlValues, searchorder:=xlByColumns, searchdirection:=xlPrevious).Column

For i = nLastCol To 22 Step -1
If InStr(1, wsCHINO.Cells(12, i).Value, "", vbTextCompare) > 0 Then
Else
Value = "TOTAL CASES"
End If
Next i

End Sub

The end goal is:

1. loop through all the tabs and find the next empty cell in row 12.
2. Then add "Total Cases" in that empty cell.
3. put in a sum formula and autofill down.

### Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},\$Z\$1:\$Z\$99,\$Y\$1:\$Y\$99),2,False) to lookup Y values to left of Z values.

#### Rick Rothstein

##### MrExcel MVP
Does this macro do what you want...
Code:
``````Sub TotalCases()
Dim LastCol As Range, WS As Worksheet
For Each WS In Worksheets
Set LastCol = WS.Rows(12).Find("*", , xlValues, , xlByColumns, xlPrevious)
If Not LastCol Is Nothing Then
If LastCol.Column > 22 Then Cells(12, LastCol.Column + 1).Value = "Total Cases"
End If
Next
End Sub``````

Replies
5
Views
414
Replies
5
Views
378
Replies
7
Views
81
Replies
6
Views
298
Replies
7
Views
167

1,133,271
Messages
5,657,757
Members
418,411
Latest member
Excellency

### 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.

### Which adblocker are you using?

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

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