+ Reply to Thread
Results 1 to 2 of 2

Inserting new columns and modifying existing VBA related code

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Inserting new columns and modifying existing VBA related code

    First of I spent some time this morning trying to learn the basics of VBA and that's about the extent of my knowledge of it.
    While I spend a great deal of time on excel work. I have never incorporated the use of VBA in it.


    I found this auto-fill calendar online and would like to insert some rows in between on the To DO list.
    Unlike excel the VBA code does not update so can someone tell me what I would need to change if I want to move the existing columns?
    Calendar Template2.xlsm

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Inserting new columns and modifying existing VBA related code

    Hi kriminaal,

    Try this:

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim KeyCells As Range, LastRow As Long, w As Worksheet
        LastRow = Range("A" & Rows.Count).End(xlUp).Row
        Set w = Sheets("Completed")
        
        ' The variable KeyCells contains the cells that will
        ' cause the macro to run when changed
        Set KeyCells = Range("D2:D" & LastRow)
        
        If Target.Count > 1 Then Exit Sub
        
        If Not Application.Intersect(KeyCells, Range(Target.Address)) _
               Is Nothing Then
      
        If Target.Value <> "" Then
            Target.EntireRow.Copy _
                w.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
            Target.EntireRow.Delete Shift:=xlUp
        End If
      End If
    End Sub
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ 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. Modifying existing code to save worksheet
    By Woopwoop in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-26-2015, 08:54 PM
  2. Modifying existing code
    By rhouston08 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2015, 06:03 PM
  3. Inserting rows between existing related data on another sheet
    By GDC in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2013, 10:45 PM
  4. [SOLVED] Add two more columns, modifying an existing VBA code help.
    By Anka in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 02-17-2013, 01:24 PM
  5. Help modifying existing VBA code
    By camcafe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2008, 11:02 AM

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