Consulting

Results 1 to 2 of 2

Thread: VBA pull first 4 digits until the bottom of the data

  1. #1

    VBA pull first 4 digits until the bottom of the data

    I need to setup vba to look at a sheet, call it sheet 1 and pull the first 4 digits (into sheet 2) until it gets to the bottom of sheet 1
    Thanks

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Sub test()
    
    Dim r1 As Range, r2 As Range
    Set r1 = Sheet1.Columns(1).SpecialCells(2)
    Set r2 = Sheet2.Range(r1.Address)
    r2.FormulaR1C1 = "=LEFT(Sheet1!RC,4)*1"
    With Sheet2.UsedRange.Columns(1)
        .Value = .Value
    End With
    End Sub
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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