PC Review


Reply
Thread Tools Rate Thread

Copying from one worksheet to another worksheet

 
 
=?Utf-8?B?R2VuZQ==?=
Guest
Posts: n/a
 
      23rd May 2007
Can't find my original post. Thank you to all who provided input to the
original post. Here is what I currently use (called from a toolbar):
Sub SelectItem()
'
' SelectItem Macro
' Macro recorded 05/21/2007 by EuGene C. White, CNA
'
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Sheets("Orders").Select
Range("ID").Select
Selection.Copy
Range("A31").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
' Insert code for date here?
Range("B31").Select
ActiveCell.FormulaR1C1 = "=NOW()"
Range("O_STSC").Select
Application.CutCopyMode = False
Selection.Copy
Range("C31").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Range("O_TEBC2").Select
Application.CutCopyMode = False
Selection.Copy
Range("D31").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Range("O_TPPC").Select
Application.CutCopyMode = False
Selection.Copy
Range("E31").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Range("F31").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(RC[-3],RC[-2],RC[-1])"
Range("O_FSP").Select
Selection.Copy
Range("G31").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A31:G31").Select
Selection.Copy
Sheets("Profit_Loss_Statement").Select
Range("A2").Select
Do Until Cells(ActiveCell.Row + 1, 1) = ""

If ActiveCell = "" Then
ActiveCell.Offset(1, 1).Select
Else
Cells(ActiveCell.Row + 1, 1).Select
End If
Loop
Cells(ActiveCell.Row + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Sheets("Orders").Select
Range("A31:G31").Select
Selection.ClearContents
Range("ID").Select
Application.CutCopyMode = False
End Sub

Might not be the best solution, but it works. I have not done any Excel VBA
before, just Word and VBScript.
/s/ Gene
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      23rd May 2007
You should try to do withOUT selections as they are rarely necessary and
slow down code. You probably won't need the application off/on.
Use the with statement as you did with those. Don't forget to put the .
s in the right places.

SelectItem Macro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With

with Sheets("Orders")
.range("A31").value=.Range("ID")
.Range("A31")=NOW()
.Range("C1").value=.Range("OF_SETS")
'etc
Range("OF_TEBC2").Select
Application.CutCopyMode = False
Selection.Copy
Range("D31").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Range("O_TPPC").Select
Application.CutCopyMode = False
Selection.Copy
Range("E31").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Range("F31").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(RC[-3],RC[-2],RC[-1])"
Range("O_FSP").Select
Selection.Copy
Range("G31").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'------
.Range("A31:G31").Copy Sheets("Profit_Loss_Statement").Range("A2")

'????
Do Until Cells(ActiveCell.Row + 1, 1) = ""
If ActiveCell = "" Then
ActiveCell.Offset(1, 1).Select
Else
Cells(ActiveCell.Row + 1, 1).Select
End If
Loop
Cells(ActiveCell.Row + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Sheets("Orders").Range("A31:G31").ClearContents

' Range("ID").Select
Application.CutCopyMode = False


With Application
.ScreenUpdating =true
.EnableEvents =true
End With

End Sub


--
Don Guillett
SalesAid Software
(E-Mail Removed)
"Gene" <(E-Mail Removed)> wrote in message
news:80250D76-3F03-43B3-93E3-(E-Mail Removed)...
> Can't find my original post. Thank you to all who provided input to the
> original post. Here is what I currently use (called from a toolbar):
> Sub SelectItem()
> '
> ' SelectItem Macro
> ' Macro recorded 05/21/2007 by EuGene C. White, CNA
> '
> With Application
> .ScreenUpdating = False
> .EnableEvents = False
> End With
> Sheets("Orders").Select
> Range("ID").Select
> Selection.Copy
> Range("A31").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> ' Insert code for date here?
> Range("B31").Select
> ActiveCell.FormulaR1C1 = "=NOW()"
> Range("O_STSC").Select
> Application.CutCopyMode = False
> Selection.Copy
> Range("C31").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Range("O_TEBC2").Select
> Application.CutCopyMode = False
> Selection.Copy
> Range("D31").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Range("O_TPPC").Select
> Application.CutCopyMode = False
> Selection.Copy
> Range("E31").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Range("F31").Select
> Application.CutCopyMode = False
> ActiveCell.FormulaR1C1 = "=SUM(RC[-3],RC[-2],RC[-1])"
> Range("O_FSP").Select
> Selection.Copy
> Range("G31").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False
> Application.CutCopyMode = False
> Range("A31:G31").Select
> Selection.Copy
> Sheets("Profit_Loss_Statement").Select
> Range("A2").Select
> Do Until Cells(ActiveCell.Row + 1, 1) = ""
>
> If ActiveCell = "" Then
> ActiveCell.Offset(1, 1).Select
> Else
> Cells(ActiveCell.Row + 1, 1).Select
> End If
> Loop
> Cells(ActiveCell.Row + 1, 1).Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Sheets("Orders").Select
> Range("A31:G31").Select
> Selection.ClearContents
> Range("ID").Select
> Application.CutCopyMode = False
> End Sub
>
> Might not be the best solution, but it works. I have not done any Excel
> VBA
> before, just Word and VBScript.
> /s/ Gene


 
Reply With Quote
 
=?Utf-8?B?R2VuZQ==?=
Guest
Posts: n/a
 
      24th May 2007
Don,
Thank you very much. Learning Excel VBA should be rather easy with folks
like you to assist me.
/s/ Gene

"Don Guillett" wrote:

> You should try to do withOUT selections as they are rarely necessary and
> slow down code. You probably won't need the application off/on.
> Use the with statement as you did with those. Don't forget to put the .
> s in the right places.
>
> SelectItem Macro
> With Application
> .ScreenUpdating = False
> .EnableEvents = False
> End With
>
> with Sheets("Orders")
> .range("A31").value=.Range("ID")
> .Range("A31")=NOW()
> .Range("C1").value=.Range("OF_SETS")
> 'etc
> Range("OF_TEBC2").Select
> Application.CutCopyMode = False
> Selection.Copy
> Range("D31").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Range("O_TPPC").Select
> Application.CutCopyMode = False
> Selection.Copy
> Range("E31").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Range("F31").Select
> Application.CutCopyMode = False
> ActiveCell.FormulaR1C1 = "=SUM(RC[-3],RC[-2],RC[-1])"
> Range("O_FSP").Select
> Selection.Copy
> Range("G31").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False
> Application.CutCopyMode = False
> '------
> .Range("A31:G31").Copy Sheets("Profit_Loss_Statement").Range("A2")
>
> '????
> Do Until Cells(ActiveCell.Row + 1, 1) = ""
> If ActiveCell = "" Then
> ActiveCell.Offset(1, 1).Select
> Else
> Cells(ActiveCell.Row + 1, 1).Select
> End If
> Loop
> Cells(ActiveCell.Row + 1, 1).Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
>
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Sheets("Orders").Range("A31:G31").ClearContents
>
> ' Range("ID").Select
> Application.CutCopyMode = False
>
>
> With Application
> .ScreenUpdating =true
> .EnableEvents =true
> End With
>
> End Sub
>
>
> --
> Don Guillett
> SalesAid Software
> (E-Mail Removed)
> "Gene" <(E-Mail Removed)> wrote in message
> news:80250D76-3F03-43B3-93E3-(E-Mail Removed)...
> > Can't find my original post. Thank you to all who provided input to the
> > original post. Here is what I currently use (called from a toolbar):
> > Sub SelectItem()
> > '
> > ' SelectItem Macro
> > ' Macro recorded 05/21/2007 by EuGene C. White, CNA
> > '
> > With Application
> > .ScreenUpdating = False
> > .EnableEvents = False
> > End With
> > Sheets("Orders").Select
> > Range("ID").Select
> > Selection.Copy
> > Range("A31").Select
> > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> > SkipBlanks:=False, Transpose:=False
> > ' Insert code for date here?
> > Range("B31").Select
> > ActiveCell.FormulaR1C1 = "=NOW()"
> > Range("O_STSC").Select
> > Application.CutCopyMode = False
> > Selection.Copy
> > Range("C31").Select
> > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> > SkipBlanks:=False, Transpose:=False
> > Range("O_TEBC2").Select
> > Application.CutCopyMode = False
> > Selection.Copy
> > Range("D31").Select
> > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> > SkipBlanks:=False, Transpose:=False
> > Range("O_TPPC").Select
> > Application.CutCopyMode = False
> > Selection.Copy
> > Range("E31").Select
> > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> > SkipBlanks:=False, Transpose:=False
> > Range("F31").Select
> > Application.CutCopyMode = False
> > ActiveCell.FormulaR1C1 = "=SUM(RC[-3],RC[-2],RC[-1])"
> > Range("O_FSP").Select
> > Selection.Copy
> > Range("G31").Select
> > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> > SkipBlanks _
> > :=False, Transpose:=False
> > Application.CutCopyMode = False
> > Range("A31:G31").Select
> > Selection.Copy
> > Sheets("Profit_Loss_Statement").Select
> > Range("A2").Select
> > Do Until Cells(ActiveCell.Row + 1, 1) = ""
> >
> > If ActiveCell = "" Then
> > ActiveCell.Offset(1, 1).Select
> > Else
> > Cells(ActiveCell.Row + 1, 1).Select
> > End If
> > Loop
> > Cells(ActiveCell.Row + 1, 1).Select
> > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> > SkipBlanks:=False, Transpose:=False
> > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> > SkipBlanks:=False, Transpose:=False
> > Sheets("Orders").Select
> > Range("A31:G31").Select
> > Selection.ClearContents
> > Range("ID").Select
> > Application.CutCopyMode = False
> > End Sub
> >
> > Might not be the best solution, but it works. I have not done any Excel
> > VBA
> > before, just Word and VBScript.
> > /s/ Gene

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying a worksheet witrh protected cells to a new worksheet =?Utf-8?B?Sm9obg==?= Microsoft Excel Worksheet Functions 1 1st Feb 2006 02:19 PM
Re: Copying a worksheet witrh protected cells to a new worksheet Tiscali NewsGroup Microsoft Excel Worksheet Functions 0 31st Jan 2006 11:11 PM
Copying worksheet and pasting on new worksheet, it makes page bre =?Utf-8?B?ZXhjZWwgcXVlc3Rpb24=?= Microsoft Excel Worksheet Functions 2 24th Oct 2004 12:41 AM
Copying Worksheet triggers Click event of combobox on another worksheet Robert Microsoft Excel Programming 0 23rd Jan 2004 07:40 PM
Copying a Carry Forward Balance from Worksheet to Worksheet =?Utf-8?B?Sm8tRlQ=?= Microsoft Excel Misc 1 24th Oct 2003 07:34 PM


Features
 

Advertising
 

Newsgroups
 


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