[SOLVED] copy Tabss, based on two criteria in column J and paste values


"Excel VBA Help"

 


Play Friv Now - Play Friv Games
Go Back   The Code Cage Forums > Microsoft Topics > Microsoft Excel Forum
Our Info Pages:-
The Code Cage - Microsoft Office help

Notices

Microsoft Excel Forum Members Post questions in this forum if they are related to using Microsoft Excel, this includes Worksheet Functions, Excel VBA Programming, Simple Macro Code & Charting, Excel formula etc.

 
 
Thread Tools Rate Thread Display Modes
  #1  
Old 13th December 2013, 02:39
marreco's Avatar
marreco marreco is offline
Valued Member
MS Office Version: MS Office 2007
MS Office Skill Level: No VBA Skills
 
Join Date: Jul 2011
Location: ES
Age: 35
Posts: 515
Posts Per Day: 0.22
My Top Tip Count: 0
Thanks to others: 92
Thanked 2 Times in 2 Posts
Reputation: 34 (12) marreco is on a distinguished road
Brazil
Default copy Tabss, based on two criteria in column J and paste values
     Excel: VBA   


------ Register to get rid of these "In Post" ads! ------

Category: Excel: VBA   

Hi.
the code below works, but for what I need two things missing.

1 Copy all data from all tabs but only if it is equal to 1 or 2 in column J

2 Copy and paste values
VBA CODE:
Public Sub Marreco() 
    Dim ws  As Worksheet, _ 
    LR1 As Long, _ 
    LR2 As Long 
     'Dest As Range
     'Set Dest = Sheets("Destination").Range("A" & LR1)
    Application.ScreenUpdating = False 
    For Each ws In ActiveWorkbook.Worksheets 
        If ws.Name <> "Destination" Then 
            LR1 = Sheets("Destination").Range("A" & Rows.Count).End(xlUp).Row + 1 
            LR2 = ws.Range("J" & Rows.Count).End(xlUp).Row 
            ws.Range("A11:J" & LR2).Copy Destination:=Sheets("Destination").Range("A" & LR1) 
             'ws.Range("A11:J" & LR2).Copy
             'Dest.PasteSpecial xlPasteValues
        End If 
    Next ws 
    Application.ScreenUpdating = True 
End Sub 



The Code Cage Advertisment
Advertisement
  #2  
Old 13th December 2013, 12:17
snb's Avatar
snb snb is offline
Forum VIP
MS Office Version: > Office 97
MS Office Skill Level: Interested
 
Join Date: Feb 2011
Location: Europe
Posts: 1,393
Posts Per Day: 0.57
My Top Tip Count: 0
Thanks to others: 0
Thanked 314 Times in 307 Posts
Reputation: 5076 (70) snb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond repute
Default Re: copy Tabss, based on two criteria in column J and paste values

------ Register to get rid of these "In Post" ads! ------


VBA CODE:
 
Sub M_snb() 
    For Each sh In sheets 
        If sh.Name <> "Destination" And (sh.cells(1,9)=1 Or sh.cells(1,9)=2) Then 
            With sh.cells(1).currentregion.resize(9).offset(10) 
                Sheets("Destination").cells(Rows.Count,1).End(xlUp).offset(1).resize(.rows.count,.columns.count)=.value 
            End With 
        End If 
    Next 
End Sub 



  #3  
Old 13th December 2013, 12:42
marreco's Avatar
marreco marreco is offline
Valued Member
MS Office Version: MS Office 2007
MS Office Skill Level: No VBA Skills
 
Join Date: Jul 2011
Location: ES
Age: 35
Posts: 515
Posts Per Day: 0.22
My Top Tip Count: 0
Thanks to others: 92
Thanked 2 Times in 2 Posts
Reputation: 34 (12) marreco is on a distinguished road
Brazil
Default Re: copy Tabss, based on two criteria in column J and paste values

------ Register to get rid of these "In Post" ads! ------


Hi.
I tried to adapt, but it did not work

look my file
Attached Files To view attachments in this forum your post count must be 2 or greater. You currently have 0 posts.



The Code Cage Advertisment
Advertisement
  #4  
Old 13th December 2013, 14:38
snb's Avatar
snb snb is offline
Forum VIP
MS Office Version: > Office 97
MS Office Skill Level: Interested
 
Join Date: Feb 2011
Location: Europe
Posts: 1,393
Posts Per Day: 0.57
My Top Tip Count: 0
Thanks to others: 0
Thanked 314 Times in 307 Posts
Reputation: 5076 (70) snb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond repute
Default Re: copy Tabss, based on two criteria in column J and paste values

------ Register to get rid of these "In Post" ads! ------


Unmerge all merged cells



  #5  
Old 13th December 2013, 15:03
marreco's Avatar
marreco marreco is offline
Valued Member
MS Office Version: MS Office 2007
MS Office Skill Level: No VBA Skills
 
Join Date: Jul 2011
Location: ES
Age: 35
Posts: 515
Posts Per Day: 0.22
My Top Tip Count: 0
Thanks to others: 92
Thanked 2 Times in 2 Posts
Reputation: 34 (12) marreco is on a distinguished road
Brazil
Default Re: copy Tabss, based on two criteria in column J and paste values

------ Register to get rid of these "In Post" ads! ------


Hi

i do it, doesn't work!




  #6  
Old 13th December 2013, 16:23
snb's Avatar
snb snb is offline
Forum VIP
MS Office Version: > Office 97
MS Office Skill Level: Interested
 
Join Date: Feb 2011
Location: Europe
Posts: 1,393
Posts Per Day: 0.57
My Top Tip Count: 0
Thanks to others: 0
Thanked 314 Times in 307 Posts
Reputation: 5076 (70) snb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond repute
Default Re: copy Tabss, based on two criteria in column J and paste values

------ Register to get rid of these "In Post" ads! ------


Read the code, analyse it, adapt it.



The Code Cage Advertisment
Advertisement
  #7  
Old 13th December 2013, 19:26
marreco's Avatar
marreco marreco is offline
Valued Member
MS Office Version: MS Office 2007
MS Office Skill Level: No VBA Skills
 
Join Date: Jul 2011
Location: ES
Age: 35
Posts: 515
Posts Per Day: 0.22
My Top Tip Count: 0
Thanks to others: 92
Thanked 2 Times in 2 Posts
Reputation: 34 (12) marreco is on a distinguished road
Brazil
Default Re: copy Tabss, based on two criteria in column J and paste values

------ Register to get rid of these "In Post" ads! ------


I've had adapted, but I could not make it work.

Thank you!

http://www.excelforum.com/excel-prog...ml#post3510837

------------------------------ posted after 39 minutes of original post ------------------------------

Hi
thank you!!

was solved in
http://www.excelforum.com/excel-prog...te-values.html


Last edited by marreco; 13th December 2013 at 19:26.


The Code Cage Advertisment
Advertisement
 
The Code Cage at Facebookhe Code Cage at Twitter


Tags
based, column, copy, criteria, paste, tabss, values

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

The Code Cage Affilliates



http://www.thecodecage.com/forumz tested by McAfee Security http://www.thecodecage.com/forumz tested by McAfee Security

All times are GMT +1. The time now is 02:08.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Template-Modifications by TMS
No part of this board, functionality or creatives may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
Copyright ©2008 - , Simon lloyd.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application they represent and are used with permission from Microsoft
UA-8135493-1
Cultural Forum | Study at Malaysian University
X vBulletin 3.8.7 Debug Information
  • Page Generation 0.20870 seconds
  • Memory Usage 6,528KB
  • Queries Executed 18 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footerEnd
  • (1)ad_footerStart
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_headerEnd
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_leftcolumn_code
  • (1)ad_navbar_below
  • (4)ad_postbit_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (7)helpful_answers
  • (1)helpfulanswers_javascript
  • (1)navbar
  • (3)navbar_link
  • (3)navbar_noticebit
  • (52)option
  • (7)post_thanks_box
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (1)postbit_attachment
  • (7)postbit_ctoptip
  • (7)postbit_onlinestatus
  • (37)postbit_reputation
  • (7)postbit_wrapper
  • (1)showthread_changepostsowner_link
  • (1)showthread_extra_fields
  • (1)showthread_quickreply_mrgdp
  • (1)showthread_reason_popup
  • (1)spacer_close
  • (1)spacer_open
  • (1)su_form
  • (7)tagbit
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_datastore.php
  • ./includes/class_hook.php
  • ./awcoding/plugins/awc.php
  • ./awcoding/plugins/ds.php
  • ./awcoding/plugins/ss.php
  • ./includes/functions_notice.php
  • ./mobiquo/smartbanner.php
  • ./mobiquo/include/classTTConnection.php
  • ./mobiquo/smartbanner/head.inc.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/vbatags.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php
  • ./includes/functions_misc.php 

Hooks Called:
  • init_startup
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_check_criteria
  • notices_noticebit
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • helpfulanswers_showthreadorpost
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • helpfulanswers_show_normal
  • reputation_power
  • reputation_image
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • error_fetch
  • postbit_attachment
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete