Results 1 to 9 of 9

Code to run to currently populated cells

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Code to run to currently populated cells

    Hi all

    I am using the following code to insert two new columns and then put the weeknum and L2 in each, and then delete an unwanted cell, my question is that my data sped changes each week this week it had 198 next week it may only be 180 or 80 how do i change the code so it only goes as far as whats in cells C.
    I am new to this and trying to learn as i go so any help would be good.

    Thanks you.

    Sub Line2()
    '
    ' Line2 Macro
    '
    
    '
        Columns("A:B").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        Range("A2").Select
        ActiveCell.FormulaR1C1 = "=WEEKNUM(RC[2])"
        Range("A2").Select
        Selection.AutoFill Destination:=Range("A2:A198"), Type:=xlFillDefault
        Range("A2:A198").Select
        ActiveWindow.SmallScroll Down:=-219
        Range("B2").Select
        ActiveCell.FormulaR1C1 = "L2"
        Selection.AutoFill Destination:=Range("B2:B198"), Type:=xlFillCopy
        Range("B2:B198").Select
        ActiveWindow.SmallScroll Down:=-18
        Columns("F:F").Select
        Selection.Delete Shift:=xlToLeft
    End Sub
    Last edited by OillyBob55; 04-23-2017 at 04:25 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA code not to continue Macro unless unless all relative cells populated
    By bdouglas1011 in forum Excel Programming / VBA / Macros
    Replies: 38
    Last Post: 09-02-2014, 12:27 PM
  2. Delete Cells with Specific Value and All Blank Cells Until Next Populated Cell is Checked
    By rdtrahan1906 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2014, 05:50 PM
  3. [SOLVED] VBA help to limit code application to populated cells
    By shootstill in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-28-2014, 06:13 PM
  4. [SOLVED] How can I modify my current code to not change once populated
    By Dena in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-05-2013, 01:52 PM
  5. 2010 VBA Code for: format the print area to include only rows with populated cells
    By sambo24 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-19-2013, 10:57 AM
  6. Replies: 4
    Last Post: 01-31-2012, 01:08 PM
  7. Conditional formulas: color code text populated cells?
    By TKT in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-28-2005, 10:05 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