+ Reply to Thread
Results 1 to 5 of 5

Delete range based columns in sheet 1

Hybrid View

cpramesh Delete range based columns in... 05-31-2017, 05:25 AM
Special-K Re: Delete range based... 05-31-2017, 05:44 AM
JOHN H. DAVIS Re: Delete range based... 05-31-2017, 08:16 AM
cpramesh Re: Delete range based... 06-02-2017, 02:04 AM
JOHN H. DAVIS Re: Delete range based... 06-05-2017, 06:55 AM
  1. #1
    Registered User
    Join Date
    04-04-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    89

    Delete range based columns in sheet 1

    In "Sheet 1" name of the worksheet, starting column and ending column mentioned. Need to delete based on the input of all sheets.
    Attached Files Attached Files
    Last edited by cpramesh; 06-02-2017 at 02:04 AM.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,082

    Re: Delete range based columns in sheet 1

    Am no VBA expert, but this seems to work

    Sub DelColumns()
    lastrow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
    For i = 2 To lastrow
    ShtNm = Worksheets("Sheet1").Cells(i, 1)
    ColFrm = Worksheets("Sheet1").Cells(i, 2)
    ColTo = Worksheets("Sheet1").Cells(i, 3)
    Worksheets(ShtNm).Range(ColFrm & ":" & ColTo).Delete
    Next i
    End Sub
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete range based columns in sheet 1

    Not sure of what you're after? Does this help?

    Sub cprameshz()
    Dim i As Long
    With Sheets("Sheet1")
        For i = 2 To .Range("A" & Rows.Count).End(3).row
            Sheets(.Cells(i, "A").Value).Columns(.Cells(i, "B") & ":" & .Cells(i, "C")).Delete
        Next i
    End With
    End Sub

  4. #4
    Registered User
    Join Date
    04-04-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Delete range based columns in sheet 1

    John your code is working well. Thank you

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete range based columns in sheet 1

    You're welcome. Glad to help out and thanks for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Cut Row to New Sheet, Delete From Previous - based on value in two different columns
    By gennalaura in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2017, 12:40 AM
  2. [SOLVED] Delete Sheet Rows & Columns based on cell value
    By brendangroff in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-10-2016, 05:22 PM
  3. Delete Columns( From One Sheet) based on the header name from a list.
    By v_a_royston in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-29-2015, 08:07 PM
  4. Dynamically fill range of columns based on value of cell in another sheet
    By indba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2014, 01:56 AM
  5. Creating a macro to delete columns based on a Range
    By 10999989 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-15-2013, 02:14 AM
  6. How to delete specific columns based on a named range of values from a worksheet
    By dronofrio in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-12-2012, 10:56 AM
  7. Macro to add sheet, name it based on previous sheet, and delete a range of cells
    By Moeshell in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-24-2011, 03:26 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1