Re: $$Excel-Macros$$ Question on VBA
Thanks Rakesh, as I would like to get the copy range changed depending on the variable I set in the macro. Actually, the code I wrote is something like below x = worksheetfunction.counta(worksheets("Sheet1").range("a:a")) worksheets("Sheet1").range(cells(3,1),cells(x,1)).copy . . Sorry I am new in VBA so what I wrote may sound silly and I do know it should have tons of better methods, would you please share it to me? On 6月29日, 上午12時03分, Rakesh Joshi wrote: > *instead of : you should use , while using cells in range reference* > > > > > > > > > > On Tue, Jun 28, 2011 at 6:12 PM, Ming wrote: > > Hi all, > > > I have written below syntax but got an error but I can't figure out > > why > > > worksheets("sheet1").range(cells(x,1):cells(x,6).copy > > worksheets("sheet2").range(cells(y,1),cells(y,6)) > > > However, I can do it if I seperate it as follows: > > > worksheets("sheet1").range(cells(x,1):cells(x,6).copy > > worksheets("sheet2").activate > > worksheets("sheet2").range(cells(y,1),cells(y,6)).pastespecial > > > Would you please let us know what's the problem? > > > -- > > > --- > > --- > > Some important links for excel users: > > 1. Follow us on TWITTER for tips tricks and links : > >http://twitter.com/exceldailytip > > 2. Join our LinkedIN group @http://www.linkedin.com/groups?gid=1871310 > > 3. Excel tutorials athttp://www.excel-macros.blogspot.com > > 4. Learn VBA Macros athttp://www.quickvba.blogspot.com > > 5. Excel Tips and Tricks athttp://exceldailytip.blogspot.com > > > To post to this group, send email to excel-macros@googlegroups.com > > > <><><><><><><><><><><><><><><><><><><><><><> > > Like our page on facebook , Just follow below link > >http://www.facebook.com/discussexcel > > -- > Rakesh Joshi -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel
Re: $$Excel-Macros$$ Question on VBA
Thanks Daniel, Sorry I missed this in the post but actually I wrote this in one line in the macro, but it doesn't work. The book tells me I shouldn't need to activate the worksheet by indicating worksheets("XXX") in the code. I believe I should have interpreted sth wrong, would you please point this out. ** I have checked the "help" in VBA for copy but it doesn't point me to the right direction... as I thought whether copy is function need to activate the sheet to perform, On 6月29日, 上午12時10分, "Daniel" wrote: > Hi, > > worksheets("sheet1").range(cells(x,1):cells(x,6).copy > worksheets("sheet2").range(cells(y,1),cells(y,6)) > > is one same line so you have to add an underscore mark : > > worksheets("sheet1").range(cells(x,1):cells(x,6).copy _ > worksheets("sheet2").range(cells(y,1),cells(y,6)) > > Regards. > Daniel > > -Message d'origine- > De : excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] De > la part de Ming > Envoyé : mardi 28 juin 2011 14:42 > À : MS EXCEL AND VBA MACROS > Objet : $$Excel-Macros$$ Question on VBA > > Hi all, > > I have written below syntax but got an error but I can't figure out why > > worksheets("sheet1").range(cells(x,1):cells(x,6).copy > worksheets("sheet2").range(cells(y,1),cells(y,6)) > > However, I can do it if I seperate it as follows: > > worksheets("sheet1").range(cells(x,1):cells(x,6).copy > worksheets("sheet2").activate > worksheets("sheet2").range(cells(y,1),cells(y,6)).pastespecial > > Would you please let us know what's the problem? > > -- > --- - > -- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links > :http://twitter.com/exceldailytip2. Join our LinkedIN group > @http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials athttp://www.excel-macros.blogspot.com > 4. Learn VBA Macros athttp://www.quickvba.blogspot.com5. Excel Tips and > Tricks athttp://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > Like our page on facebook , Just follow below > linkhttp://www.facebook.com/discussexcel -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel
Re: $$Excel-Macros$$ Question on VBA
*instead of : you should use , while using cells in range reference* On Tue, Jun 28, 2011 at 6:12 PM, Ming wrote: > Hi all, > > I have written below syntax but got an error but I can't figure out > why > > worksheets("sheet1").range(cells(x,1):cells(x,6).copy > worksheets("sheet2").range(cells(y,1),cells(y,6)) > > However, I can do it if I seperate it as follows: > > worksheets("sheet1").range(cells(x,1):cells(x,6).copy > worksheets("sheet2").activate > worksheets("sheet2").range(cells(y,1),cells(y,6)).pastespecial > > Would you please let us know what's the problem? > > -- > > -- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links : > http://twitter.com/exceldailytip > 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials at http://www.excel-macros.blogspot.com > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > Like our page on facebook , Just follow below link > http://www.facebook.com/discussexcel > -- Rakesh Joshi -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel
RE: $$Excel-Macros$$ Question on VBA
Hi, worksheets("sheet1").range(cells(x,1):cells(x,6).copy worksheets("sheet2").range(cells(y,1),cells(y,6)) is one same line so you have to add an underscore mark : worksheets("sheet1").range(cells(x,1):cells(x,6).copy _ worksheets("sheet2").range(cells(y,1),cells(y,6)) Regards. Daniel -Message d'origine- De : excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] De la part de Ming Envoyé : mardi 28 juin 2011 14:42 À : MS EXCEL AND VBA MACROS Objet : $$Excel-Macros$$ Question on VBA Hi all, I have written below syntax but got an error but I can't figure out why worksheets("sheet1").range(cells(x,1):cells(x,6).copy worksheets("sheet2").range(cells(y,1),cells(y,6)) However, I can do it if I seperate it as follows: worksheets("sheet1").range(cells(x,1):cells(x,6).copy worksheets("sheet2").activate worksheets("sheet2").range(cells(y,1),cells(y,6)).pastespecial Would you please let us know what's the problem? -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel
$$Excel-Macros$$ Question on VBA
Hi all, I have written below syntax but got an error but I can't figure out why worksheets("sheet1").range(cells(x,1):cells(x,6).copy worksheets("sheet2").range(cells(y,1),cells(y,6)) However, I can do it if I seperate it as follows: worksheets("sheet1").range(cells(x,1):cells(x,6).copy worksheets("sheet2").activate worksheets("sheet2").range(cells(y,1),cells(y,6)).pastespecial Would you please let us know what's the problem? -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel