Results 1 to 6 of 6

Need Additional Macro Code to clear out data from secondary Page after data has been chang

Threaded View

  1. #1
    Registered User
    Join Date
    03-13-2014
    Location
    Green Bay, WI
    MS-Off Ver
    Excel 2007
    Posts
    13

    Need Additional Macro Code to clear out data from secondary Page after data has been chang

    I received help from here a while back regarding macro code (PREVIOUS THREAD => macro if data in column a = set word to insert that column into sheet 2 or 3 based on word). I am having a problem now where if data is changed in the main spreadsheet the secondary spreadsheets are retaining that formula rather than clearing it from the previous secondary and putting it to a new secondary. Below is the code that is being used in the document.
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim lRow As Long
    Dim rng As Range
    Dim ws As Worksheet
    
    If Selection.Count > 1 Then Exit Sub
    
    If Not Intersect(Target, Range("A:A")) Is Nothing Then
        On Error Resume Next
        Set ws = Sheets(Range("A" & Target.Row).Value)
        On Error GoTo 0
        If ws Is Nothing Then
            MsgBox "That team does not have a tab created"
        Else
            With ws
                lRow = .Range("A" & Rows.Count).End(xlUp).Row + 1
                .Cells(lRow, 1).Value = Range("A" & Target.Row).Value
                For Each rng In .Range("B" & lRow & ":J" & lRow)
                    rng.Formula = "='CRH Projects'!" & Left(rng.Address(False, False), 1) & Target.Row
                Next rng
            End With
        End If
    End If
    
    End Sub
    Last edited by Leith Ross; 11-03-2014 at 06:17 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to clear row data then shift remaining data up to empty rows.
    By clarmech in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-15-2014, 04:35 PM
  2. Found a code to merge two data sheets but I need additional help.
    By floydian in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-25-2013, 01:12 AM
  3. Replies: 1
    Last Post: 06-21-2013, 04:05 AM
  4. VB Code to Clear the data
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-09-2012, 03:37 PM
  5. Returning additional data from existing code
    By gss in forum Excel General
    Replies: 1
    Last Post: 04-05-2011, 09:11 AM

Tags for this Thread

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