Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-23-2020, 04:10 PM
14spar15 14spar15 is offline Problems with Clearing Contents. Windows 7 64bit Problems with Clearing Contents. Office 2010 64bit
Advanced Beginner
Problems with Clearing Contents.
 
Join Date: Mar 2011
Posts: 64
14spar15 is on a distinguished road
Default Problems with Clearing Contents.


Hello. I want to be able to select any or all of the colors in rows A1-A7 and then run my compile macro and have the selected section appear in A10-A16. This performs as expected. Now, I want to make another selection and compile without clearing A10-A16. The only way this works is if I’m selecting the same number or more colors. If I select fewer then there are still some colors left over from the previous compile. I tried to “Clear Contents” of A10-A16 in the macro before pasting the new selection but when I do this it clears my new selected selection. Thanks
Attached Files
File Type: xlsm Book1.xlsm (18.6 KB, 4 views)
Reply With Quote
  #2  
Old 11-23-2020, 07:59 PM
Logit Logit is offline Problems with Clearing Contents. Windows 10 Problems with Clearing Contents. Office 2007
Expert
 
Join Date: Jan 2017
Posts: 358
Logit will become famous soon enoughLogit will become famous soon enough
Default

Code:
Sub cpypste()
Dim InputCells As Excel.Range
Dim OutputCells As Excel.Range

    'Show input box to get range of cells that want to copy
    Set InputCells = _
    Application.InputBox(Prompt:="Select Cell / Cells To Copy", _
    Title:="Copy Paste", Type:=8)
    
    'Show input box to get where they want it paste
    Set OutputCells = _
    Application.InputBox(Prompt:="Select cell where you want paste", _
    Title:="Copy Paste", Type:=8)
    
    'Copy range of input cells
    InputCells.Copy
    
    'Paste it into output cells reference
    OutputCells.PasteSpecial (xlPasteAll)

End Sub
Reply With Quote
  #3  
Old 11-25-2020, 06:20 PM
p45cal p45cal is offline Problems with Clearing Contents. Windows 10 Problems with Clearing Contents. Office 2019
Expert
 
Join Date: Apr 2014
Posts: 438
p45cal is a name known to allp45cal is a name known to allp45cal is a name known to allp45cal is a name known to allp45cal is a name known to allp45cal is a name known to all
Default

or:
Code:
Sub CopySelectedCells()
  rw = Application.Max(10, Cells(Rows.Count, 1).End(xlUp).Row + 1)
  Selection.Copy Range("A" & rw)
End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Table of contents problems with arabic words Baby_1 Word 0 07-20-2017 01:36 AM
Problems with Clearing Contents. Clearing form wpryan Word VBA 2 09-05-2015 01:06 AM
Word 2011 for Mac - problems with table of contents tepose Word 1 09-28-2014 03:36 PM
Problems with Clearing Contents. Table of Contents problems lsmcal1984 Word 1 08-21-2013 11:51 AM
Problems with Clearing Contents. Table of Contents problems hassanfadil Word 2 06-02-2011 12:05 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 02:17 PM.


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