Hi,
How do you acheive this in 1 vba macro at the same time:
- copy/paste visible cells only from Sheet1 to Sheet2?
- copy/paste multiple different ranges?
See Attachment.
Hi,
How do you acheive this in 1 vba macro at the same time:
- copy/paste visible cells only from Sheet1 to Sheet2?
- copy/paste multiple different ranges?
See Attachment.
Last edited by Aaeijh; 02-12-2018 at 12:26 PM.
It is unclear if you are attempting to copy only rows that are not hidden, or if you are trying to copy on rows where cells are not blank. Your example indicates that it is the latter, but you need to verify that.
Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
Just when I think I am smart, I learn something new!
Clarification: only copy rows that are not hidden.
Thanks,
Take a look at this: https://msdn.microsoft.com/en-us/vba...s-method-excel
Specifically xlCellTypeVisible. You then treat it like any other range (ie: copy, paste, delete, etc)
Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.
"I am here to help, not do it for people" -Me
ok, after reading the microsoft article, I created this vba macro, but get an error:
Seems to be in the right direction, just cant pinpoint the source of the error,Please Login or Register to view this content.
See Attachment.
Well, yeah, you didn't copy, only paste. That will error every time.
Please Login or Register to view this content.
Thanks for pointing that out,
Here's the updated code, including the "Copy"
Unfortunately, its generating an error when running the macro.Please Login or Register to view this content.
- With Range("rGroup1TitleAndRows").Copy ---> ERROR: Method 'Range of Object' _Global Failed.
- With rGroup1TitleAndRows.Copy ---> ERROR: Runtime 1004, That command cannot be used on multiple selections.
Any additional thoughts on how to copy and paste a combination of ranges?
Last edited by Aaeijh; 02-13-2018 at 09:59 AM.
See if replacing this
With thisPlease Login or Register to view this content.
will work. I didn't test it.Please Login or Register to view this content.
Once again, thanks for the reply,
Here's the new code:
But this error comes up:Please Login or Register to view this content.
macro-error.jpg
Let me know how I'm doing this wrong,?!,.
Thanks,
Last edited by Aaeijh; 02-13-2018 at 10:55 AM.
if not hidden cell
Please Login or Register to view this content.
daboho,
Thanks for this,!
The code works!, but it copy/paste every visible rows,
code-vs-desired-result.jpg
In addition to copy/paste only the visible rows, we're trying to select a specific combination of ranges...
ie - programattically only select what's in blue
sheet1.jpg
Any thoughts?
Last edited by Aaeijh; 02-13-2018 at 11:56 AM.
you talk that is hidden row
if hidden row not to copy using specialcells(12)
Its a combination of both:
1. combine "specific ranges" from different rows that are not consecutive
2. only copy/paste visible rows
Sorry about that, had a glitch when I posted and did not fix it properly. Here is replacement code.
Please Login or Register to view this content.
Hi JLGWhiz,
Slightly modified your code to make it work, but it doesn't achieve the desired outcome,
code-vs-desired-outcome2.jpg
Maybe its impossible to copy/paste from multiple range, idk,
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks