tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
This code
was taken from here:
How can I change it so instead of displaying the result in a cell, I want to assign a variable to it, eg
Thanks
Rich (BB code):
Sub Test()
' file name, sheet name and column number - change to suit
Const FName As String = "P:\TEMP\MrExcel\FileLinks\[MyFile.xls]"
Const ShName As String = "Sheet1"
Const ColNo As Integer = 1
Dim ShNew As Worksheet
Dim LastRow As Long
Application.DisplayAlerts = False
Set ShNew = Worksheets.Add
With ShNew.Range("A1")
.FormulaR1C1 = "=COUNTA('" & FName & ShName & "'!C" & ColNo & ")"
LastRow = .Value
End With
ShNew.Delete
Application.DisplayAlerts = True
MsgBox LastRow
End Sub
was taken from here:
Rich (BB code):
How can I change it so instead of displaying the result in a cell, I want to assign a variable to it, eg
Rich (BB code):
Dim a as Integer
a="=COUNTA('" & FName & ShName & "'!C" & ColNo & ")"
Thanks
Last edited: