0

I got this error message when I try to count how many no-empty cells for a certain row, check several question from other people related to that, I think I already assign which tab I would like to count (DAU)

Option Explicit

Sub Adjust_col()
    Dim wb As Workbook
    Dim App_list As Long, DAU_col As Long

    Set wb = ThisWorkbook

    App_list = wb.Sheets("App Name Map").Range("B2").End(xlDown).Row

    DAU_col = wb.Sheets("DAU").Range("D4", Range("D4").End(xlToRight)).Count

    MsgBox DAU_col
End Sub

What it keep giving me the error for my Variable DAU_col, if I choose the active tab is DAU, it works well, otherwise it won't work.

GSerg
  • 76,472
  • 17
  • 159
  • 346
Worst SQL Noob
  • 189
  • 1
  • 5
  • 15
  • if you are trying to count columns between D4 and the last significant column the use `DAU_col = wb.Sheets("DAU").Range("D4", wb.Sheets("DAU").Range("D4").End(xlToRight)).Count`.. if you want the last column number then mayuse `DAU_col = wb.Sheets("DAU").Range("D4").End(xlToRight).Column` – Ahmed AU Apr 10 '19 at 05:42
  • ok, i know, i should let the Range("D4").End(xlToRight) know which tab I am using – Worst SQL Noob Apr 10 '19 at 05:50

0 Answers0