+ Reply to Thread
Results 1 to 3 of 3

Looking to add to existing VBA code to type a word in a cell in a different sheet

Hybrid View

  1. #1
    Forum Contributor Nitro2481's Avatar
    Join Date
    09-09-2014
    Location
    Laois, Ireland
    MS-Off Ver
    2013
    Posts
    323

    Looking to add to existing VBA code to type a word in a cell in a different sheet

    Hello,

    I currently have the below code in sheet 1 which transfers certain info from sheet 1 to sheet 2 & sheet 3 on a trigger of the word Block. I would also like on this trigger if the words "Sent Up" could be put in column J. this is not being copied from anywhere in sheet 1, just being input in sheet 2 and/or sheet 3.

    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("AB:AC")) Is Nothing Then
      With Target
        If UCase(.Value) = "BLOCK" Then
          If .Column = 28 Then
            CopyTo = "Sheet 2"
            rw = Sheets(CopyTo).Range("E" & Rows.Count).End(xlUp).Row + 1
            Range("B" & .Row).Copy Destination:=Sheets(CopyTo).Range("E" & rw)
            Range("AB" & .Row).Copy Destination:=Sheets(CopyTo).Range("f" & rw)
    Put "Sent Up" in Column J
        ElseIf .Column = 29 Then
                CopyTo = "Sheet 3"
            rw = Sheets(CopyTo).Range("D" & Rows.Count).End(xlUp).Row + 1
            Range("B" & .Row & ":C" & .Row).Copy Destination:=Sheets(CopyTo).Range("D" & rw)
            Range("AC" & .Row).Copy Destination:=Sheets(CopyTo).Range("F" & rw)
    Put "Sent Up" in Column J
          End If
        End If
      End With
    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Looking to add to existing VBA code to type a word in a cell in a different sheet

    Probably like this. Not sure since you didn't submit a sheet to test against

    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("AB:AC")) Is Nothing Then
      With Target
        If UCase(.Value) = "BLOCK" Then
          If .Column = 28 Then
            CopyTo = "Sheet 2"
            rw = Sheets(CopyTo).Range("E" & Rows.Count).End(xlUp).Row + 1
            Range("B" & .Row).Copy Destination:=Sheets(CopyTo).Range("E" & rw)
            Range("AB" & .Row).Copy Destination:=Sheets(CopyTo).Range("f" & rw)
            Sheets(CopyTo).Range("J" & rw).Value = "Sent Up"  'Put "Sent Up" in Column J
        ElseIf .Column = 29 Then
                CopyTo = "Sheet 3"
            rw = Sheets(CopyTo).Range("D" & Rows.Count).End(xlUp).Row + 1
            Range("B" & .Row & ":C" & .Row).Copy Destination:=Sheets(CopyTo).Range("D" & rw)
            Range("AC" & .Row).Copy Destination:=Sheets(CopyTo).Range("F" & rw)
            Sheets(CopyTo).Range("J" & rw).Value = "Sent Up" 'Put "Sent Up" in Column J
          End If
        End If
      End With
    End If
    If you are happy with my response please click the * in the lower left of my post.

  3. #3
    Forum Contributor Nitro2481's Avatar
    Join Date
    09-09-2014
    Location
    Laois, Ireland
    MS-Off Ver
    2013
    Posts
    323

    Re: Looking to add to existing VBA code to type a word in a cell in a different sheet

    Hi Stnkynts

    That worked perfect.Thanks a mil

+ 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. Replies: 2
    Last Post: 12-17-2013, 11:51 AM
  2. [SOLVED] Correct way to apply an existing VBA code to an existing sheet
    By JO505 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2013, 05:42 PM
  3. [SOLVED] Code to copy numerous sheet cell ranges to a word document on my desktop
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2013, 07:48 PM
  4. [SOLVED] Shortening VB code that deals with deleting a row if a type of word is found
    By WaqasTariq in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-18-2012, 09:51 AM
  5. copy existing code for another sheet
    By defarny37 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-27-2012, 06:51 AM
  6. Need VBA code to Copy all on a sheet to another existing sheet
    By appform in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-24-2010, 11:24 AM
  7. Replies: 1
    Last Post: 08-15-2009, 05:52 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