Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Moving row data to another sheet

I have a "sales forecast" spreadsheet, in which data is
changes from a forecast to completed.
Basicly what I would like to do is instead of our sales
people having to cut and paste the data (from one month to
another month shhet), it could be done from vba code.
The citeria would be that the row data changes (from
forecast to actual)when the user chooses from a cell
(column M) the month the order closed (months are in a
validation list). So he/she might show a project forecast
to possibly run in June and places the info in the June
sheet, the project closes in July. The use could just cut
and paste this row's info (column A to col P) from the
June sheet to the July sheet. But I'd rather have a cmd
button that goes through the sheet, finds the data and
places it into proper sheet (based upon month closed).
All help appreciated.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Moving row data to another sheet

A couple of things to do:

You will use the Change Event on either the workbook or worksheet, which
ever you prefer and depending on your situation. In this case, I'm assuming
you are going to use the Worksheet Change Event

Private Sub Worksheet_Change(ByVal Target as Range)
Dim CurRow as Long, PasteToRow as Long, PasteToMonth as String
Dim CurMonth as String
EnableEvents = False
If Target.Column = 12 Then
'Gets the Worksheet name of the active worksheet
CurMonth = Target.Parent.Name
PasteToMonth = UCase(Format(Target.Value,"MMM"))
If PasteToMonth < Target.Parent.Name Then
CurRow = Target.Row
Worksheets("CurMonth").Range("A" & CurRow & ":P" & CurRow).Copy
PasteToRow = Worksheets(PasteToMonth). _
Range("A" & HeaderRow).End(xlDown)
Worksheets(PasteToMonth).Paste
Destination:=Worksheets(PasteToMonth). _
Range("A" & PasteToRow & ":P" & PasteToRow)
Worksheets(CurMonth).Range("A" & CurRow & ":P" & CurRow). _
Delete(xlShiftUp)
End If
End If
EnableEvents = True
End Sub

Assumptions:

Each of your worksheets are named with the first 3 letter of the month in
all caps.
This is the behavior you want taken place the moment the user changes the
closed month on the project.

--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"RickK" wrote in message
...
I have a "sales forecast" spreadsheet, in which data is
changes from a forecast to completed.
Basicly what I would like to do is instead of our sales
people having to cut and paste the data (from one month to
another month shhet), it could be done from vba code.
The citeria would be that the row data changes (from
forecast to actual)when the user chooses from a cell
(column M) the month the order closed (months are in a
validation list). So he/she might show a project forecast
to possibly run in June and places the info in the June
sheet, the project closes in July. The use could just cut
and paste this row's info (column A to col P) from the
June sheet to the July sheet. But I'd rather have a cmd
button that goes through the sheet, finds the data and
places it into proper sheet (based upon month closed).
All help appreciated.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Moving row data to another sheet


Thankyou Ronald, I'll give this a try.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Moving row data to another sheet

The code, stops running at

Worksheets("CurMonth").Range("A" & CurRow & ":P" &
CurRow).Copy

And generates a "Subscript out of range" (run error 9)
message.
By the way I would want to copy from column A to Column Q.
In your orginal code please eplain the ":P" & CurRow
don't understand this.
Thnaks

-----Original Message-----
A couple of things to do:

You will use the Change Event on either the workbook or

worksheet, which
ever you prefer and depending on your situation. In this

case, I'm assuming
you are going to use the Worksheet Change Event

Private Sub Worksheet_Change(ByVal Target as Range)
Dim CurRow as Long, PasteToRow as Long, PasteToMonth

as String
Dim CurMonth as String
EnableEvents = False
If Target.Column = 12 Then
'Gets the Worksheet name of the active worksheet
CurMonth = Target.Parent.Name
PasteToMonth = UCase(Format(Target.Value,"MMM"))
If PasteToMonth < Target.Parent.Name Then
CurRow = Target.Row
Worksheets("CurMonth").Range("A" & CurRow

& ":P" & CurRow).Copy
PasteToRow = Worksheets(PasteToMonth). _
Range("A" & HeaderRow).End(xlDown)
Worksheets(PasteToMonth).Paste
Destination:=Worksheets(PasteToMonth). _
Range("A" & PasteToRow & ":P" & PasteToRow)
Worksheets(CurMonth).Range("A" & CurRow

& ":P" & CurRow). _
Delete(xlShiftUp)
End If
End If
EnableEvents = True
End Sub

Assumptions:

Each of your worksheets are named with the first 3 letter

of the month in
all caps.
This is the behavior you want taken place the moment the

user changes the
closed month on the project.

--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"RickK" wrote in message
...
I have a "sales forecast" spreadsheet, in which data is
changes from a forecast to completed.
Basicly what I would like to do is instead of our sales
people having to cut and paste the data (from one month

to
another month shhet), it could be done from vba code.
The citeria would be that the row data changes (from
forecast to actual)when the user chooses from a cell
(column M) the month the order closed (months are in a
validation list). So he/she might show a project

forecast
to possibly run in June and places the info in the June
sheet, the project closes in July. The use could just

cut
and paste this row's info (column A to col P) from the
June sheet to the July sheet. But I'd rather have a cmd
button that goes through the sheet, finds the data and
places it into proper sheet (based upon month closed).
All help appreciated.




.

Reply
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
moving data from one sheet to another SalesGuy Excel Discussion (Misc queries) 1 April 7th 10 08:54 PM
Moving data from one sheet to another Kennedy Excel Discussion (Misc queries) 2 March 10th 10 02:08 PM
Moving data from one sheet to another KevHardy Excel Discussion (Misc queries) 5 December 19th 09 07:56 PM
moving data from one sheet to another David Excel Discussion (Misc queries) 3 February 1st 07 04:58 PM
Moving Data from one sheet to another Patty Garrity Excel Programming 1 August 18th 03 06:20 PM


All times are GMT +1. The time now is 10:23 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"