+ Reply to Thread
Results 1 to 4 of 4

Deleting Columns

Hybrid View

  1. #1
    Registered User
    Join Date
    09-04-2008
    Location
    Singapore
    Posts
    24

    Deleting Columns

    Hi I've got 2 codes here,

    This:
    Delete_Info = Delete_Column.Text
    Call DelColumn(Delete_Info)
    Will call the sub procedure:
    Sub DelColumn(Delete_Info)
    
        Columns("Delete_Info:IV").Select
        Selection.Delete Shift:=xlToLeft
    End Sub
    It doesnt work. The main purpose here is to delete a few columns all the way to the last column of the file. The initial column to be selected will be from "Delete_Column.Text" (A textbox entered by a user) all the way to column IV.

    So is anyone here able to help me? I will try to provide more info if needed.
    Thanks
    Last edited by mudraker; 12-29-2008 at 07:08 AM. Reason: Mark Thread as Solved

  2. #2
    Valued Forum Contributor ffffloyd's Avatar
    Join Date
    05-20-2008
    Location
    Perth, WA, Australia
    MS-Off Ver
    Office 365
    Posts
    245
    I think you would need to change the Select part of Sub DelColumn to
    Columns(Delete_Info&":IV").Select
    otherwise you are just quoting the text "Delete_Info" instead of using its value.

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    You do not need to select before deleting
    Your 2 lines of code in DelColumn macro can be reduced to 1 line of code

    Sub DelColumn(Delete_Info)
        Columns(Delete_Info & ":IV").Delete Shift:=xlToLeft
    End Sub
    ffffloyd
    Reply is correct as to the cause of your error
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  4. #4
    Registered User
    Join Date
    09-04-2008
    Location
    Singapore
    Posts
    24
    Wow thanks a lot. Finally I can implement a new function to my User form. Moderators, this is solved =)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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