Consulting

Results 1 to 4 of 4

Thread: Solved: Need help creating macro to insert col

  1. #1
    VBAX Regular
    Joined
    Jun 2007
    Posts
    18
    Location

    Solved: Need help creating macro to insert col

    Hi, I am seeking your help with creating a macro that will delete a Col C, insert a Col A, then name it,then populate the rows to end of data in next col with user input.

    Please see example in attachment.

    Thanks,
    cgannm Attachment 9212

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub SomeCode()
    Dim myInput As Variant

    myInput = InputBox("Insert what type?")
    If myInput <> "" Then

    Columns(3).Delete
    Columns(1).Insert
    Range("A1").Value = "Tray"
    Range("A2").Resize(Range("B2").End(xlDown).Row).Value = myInput
    End If
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Jun 2007
    Posts
    18
    Location
    Hi, Xid,thanks for helping. I am have one slight problem with "A2". The input value is populating one too rows. For example, "B2" has data up to row 10, script populates "A2" up to Row 11.

    Thanks

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Slight mod

    [vba]

    Sub SomeCode()
    Dim myInput As Variant

    myInput = InputBox("Insert what type?")
    If myInput <> "" Then

    Columns(3).Delete
    Columns(1).Insert
    Range("A1").Value = "Tray"
    Range("A2").Resize(Range("B2").End(xlDown).Row - 1).Value = myInput
    End If
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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