VBScript RRS feed

  • Question

  • If I know the starting cell EG: D1 and I want to select down the column and to the right, data with non-contiguous cells i.e blank cells in middle. What is vbscript code for this.
    Friday, August 9, 2019 7:04 AM

All replies

  • john,
    re:  select a range


    Free Excel workbooks and add-ins at MediaFire

    Friday, August 9, 2019 9:57 AM
  • Suppose you have a Worksheet variable say WS and you have properly set it, then you may use something like this...

    Dim xlApp
    Dim WB
    Dim WS
    Dim LR
    Dim LC

    set xlApp=CreateObject("Excel.Application")

    Set WB=xlApp.Workbooks.Open("C:\Users\sktneer\Desktop\Test.xlsx")    'Change the File Path here
    Set WS=wb.Worksheets("Sheet1")                        'Change the Sheet Name here

    With WS
       LR = .Cells(.Rows.Count,"D").End(3)(1).Row
       LC = .Cells(LR, .Columns.Count).End(1).Column
       .Range("D1", .Cells(LR,LC)).Select
    End With

    Subodh Tiwari (Neeraj) sktneer

    Friday, August 9, 2019 7:24 PM