I have a problem with range define in vba code that below code get me error of “Object required”.
Option Explicit
Dim RowCount, ColCount, blankCount, RangeCount As Integer
Dim Rng2 as range
Sub DataWord2()
Set ExApp = CreateObject("Excel.Application")
Worksheets("Sheet4").Range("A1").Select
Set Rng2 = Worksheets("Sheet4").Range("A1")
CountCurrentRange (Rng2)
End sub
Public Function CountCurrentRange(ByVal Rng As Range) As Integer
RowCount = WorksheetFunction.CountA(Range(Rng, Range(Rng).End(xlDown)))
ColCount = WorksheetFunction.CountA(Range(Rng, Range(Rng).End(xlToRight)))
Range(Cells(Ro, Col), Cells(RowCount, ColCount)).Select
Selection.Replace What:="", `your text`Replacement:="-", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range(Cells(Ro, Col), Cells(RowCount, ColCount)).Replace What:="", Replacement:="-", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
RangeCount = WorksheetFunction.CountA(Range(Rng, Range(Rng).End(xlDown).End(xlToRight)))
End Function
I have a range of data from Excel sheet “A1” , I want count rows and columns of this range. `
2