LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Code runs different in a commandbutton than a macro why?

ok here is my code it backs up a record to another sheet

Private Sub CommandButton2_Click()

For Each c In Worksheets("ART Report").Range("P3:P10")
If c.Value = "p" Then
c.EntireRow.Copy
Sheets("Paid Recievables").Select
Set rng = Cells(Rows.Count, 1).End(xlUp)
Rows(rng.Row + 1).Select
Selection.Insert Shift:=x1Down
End If
Next

End Sub

and the the macro I first created that works:

Sub Pselect()
'
' Macro1 Macro
' Macro recorded 3/12/2003 by me
'
For Each c In Worksheets("ART Report").Range("P1:P10")
If c.Value = "p" Then
c.EntireRow.Copy
Sheets("Paid Recievables").Select
Set rng = Cells(Rows.Count, 1).End(xlUp)
Rows(rng.Row + 1).Select
Selection.Insert Shift:=x1Down
End If
Next
End Sub

also I am trying to use this bit of code to set of the range of the for statement "Set rng = Cells(Rows.Count, 1).End(xlUp)" but have not got it to work as of yet?

any help is greatly appreciated
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
vba code runs...need spaces ........ Wanna Learn Excel Discussion (Misc queries) 2 January 20th 09 12:44 PM
One macro runs then it auto runs another macro PG Excel Discussion (Misc queries) 2 September 1st 06 09:30 PM
Can you code a macro so it runs multiple times in the same workboo dpmac Excel Discussion (Misc queries) 2 April 18th 06 07:40 PM
Code runs every other time Mike Waldron Excel Programming 1 September 27th 03 03:54 PM


All times are GMT +1. The time now is 06:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"