Consulting

Results 1 to 2 of 2

Thread: Range of last used cell, Paste Data to last cell

  1. #1
    VBAX Regular
    Joined
    Aug 2014
    Posts
    49
    Location

    Unhappy Range of last used cell, Paste Data to last cell

    Hello All,

    I need help with a small project im working on.

    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!

  2. #2
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •