PDA

View Full Version : [SOLVED] Range of last used cell, Paste Data to last cell



Zlerp
08-21-2014, 11:46 AM
Hello All,

I need help with a small project im working on.:bug:

Currently Ihave:

Sub YAY()

Dim Path1 As String
Dim Msg As String
Msg = "Please Insert Path 1"
Path1 = Application.InputBox(Msg)
ActiveSheet.Range("F:F").Value = Path1
End Sub

What I am looking to do is find the Range of the last Row in Collum A that contains data, then paste Path1 in Collum F to the last used row.

for example:

If Column A has data until A157, then i want Path1 (shown in the code above) to be pasted into F1:F157

Please and thank you for your help. And if you wouldnt mind putting a bit of an explanation of how/why the help provide works that would be awesome.

Thanks Again!

JKwan
08-21-2014, 01:34 PM
try this:

Sub YAY()
Dim LastRow As Long
Dim Path1 As String
Dim Msg As String

Msg = "Please Insert Path 1"
Path1 = Application.InputBox(Msg)

' find last row of column A
LastRow = FindLastRow(ActiveSheet, "A")
ActiveSheet.Range("F1:F" & LastRow).Value = Path1
End Sub
Public Function FindLastRow(ByVal WS As Worksheet, ColumnLetter As String) As Long
' this function will find the last row of the worksheet and column that you
' request
FindLastRow = WS.Range(ColumnLetter & Rows.Count).End(xlUp).Row
End Function