Find Next Empty Cell

temerson

New Member
Joined
Apr 22, 2019
Messages
39
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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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
 
Upvote 0

Forum statistics

Threads
1,223,759
Messages
6,174,336
Members
452,555
Latest member
colc007

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