Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 12-20-2017, 11:15 AM
NoSparks NoSparks is offline Looking to copy select cells in table using dropdown list to paste to new table in another worksheet Windows 7 64bit Looking to copy select cells in table using dropdown list to paste to new table in another worksheet Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Quote:
The error shows in your code on the highlighted line .ListObjects(destTable).HeaderRowRange.Select
Opps... eliminate the error by adding the Else Exit Sub bits here
Code:
If UCase(Target.Value) = "NO" Then
    destTable = "_" & Replace(Sh.Name, " ", "_")
    ray = Split(Cells(Target.Row, "B").Value & "|" & Cells(Target.Row, "D").Value & "|" & Cells(Target.Row, "J").Value, "|")
Else
    Exit Sub
End If
Quote:
Not sure how to set that code up to remove the copied data when "YES" or blank cell selected.
The code for removal of the data from table will need to be in the above Else ahead of Exit Sub.
What is there to uniquely, positively, absolutely and unmistakenly identify the line to be removed?
(A record ID number would be a great thing to have)

Quote:
Why wont that pick up the copied data?
It was being copied as text.

The revised code
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

'limit to sheets whose name starts with 5 digits
 If Not IsNumeric(Left(Sh.Name, 5)) Then Exit Sub
'limit to single cell in column K
 If Target.Count > 1 Or Target.Column <> 11 Then Exit Sub
 
    Dim ray As Variant
    Dim oLo As ListObject
    Dim destTable As String
    Dim HderRow As Long
    Dim writeRow As Long
    Dim i As Integer
    
If UCase(Target.Value) = "NO" Then
    destTable = "_" & Replace(Sh.Name, " ", "_")
    ray = Split(Cells(Target.Row, "B").Value & "|" & Cells(Target.Row, "D").Value & "|" & Cells(Target.Row, "J").Value, "|")
Else
    'removal would be done here
    Exit Sub
End If

Application.ScreenUpdating = False

With Sheets("MONTHLY GOE RECONCILIATION")
    .Select
    .ListObjects(destTable).HeaderRowRange.Select
    HderRow = Selection.Row
    For i = 1 To 99
        If IsEmpty(.Cells(HderRow + i, 5)) Then Exit For
    Next i
    writeRow = HderRow + i
    Application.EnableEvents = False
    .Cells(writeRow, 2) = ray(0)
    .Cells(writeRow, 3) = ray(1)
    .Cells(writeRow, 4) = ray(2) * 1
    Application.EnableEvents = True
End With

Sh.Select

Application.ScreenUpdating = True

End Sub
Hope that rectifies some of the issues.
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking to copy select cells in table using dropdown list to paste to new table in another worksheet How to paste the data from one table into the cells of another table, without overwriting anything CClio333 Word Tables 1 08-12-2014 05:17 PM
Looking to copy select cells in table using dropdown list to paste to new table in another worksheet Is it possible to copy non-contiguous rows of a Table and paste them as a separate Table in Word? Joey Cheung Word Tables 1 08-12-2014 05:15 PM
Can you copy & paste cells across worksheets and preserve reference to worksheet? New Daddy Excel 2 11-27-2013 07:19 AM
Copy and paste table Patrickjm Word 1 03-19-2013 03:30 PM
Populate dropdown list with data from Access table spw4000 Office 0 02-24-2012 05:22 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft