PC Review


Reply
Thread Tools Rate Thread

Data need to be copied as per sheet name

 
 
Ranjit kurian
Guest
Posts: n/a
 
      25th Jun 2008
Hi

I have a master sheet in excel which contain all the below details as per
sheet names('status' column are the sheet names)

Status Date Patient ID Docter Name Region
Critical 6/25/2008 34567 Suhas IE
Died 6/25/2008 12345 Pradeep US

This master sheet is updated on daily bases, new recordes will been added on
daily, i need a macro so that when ever the new recordes are added to the
master sheet , all the other sheets similutaneous need to be filled example:

if the Status column is Critical then what ever details is update next to
that column need to filled in Critical Sheet.......

The macro should match the sheet name and mastersheet data , then it should
copy the related details to that particular sheet

 
Reply With Quote
 
 
 
 
Susan
Guest
Posts: n/a
 
      25th Jun 2008
well, no one else has tried, so i'll give it a go. please save your
work before running this macro. i did not make it an automatic
worksheet_change as you requested, because it would be running
constantly & would not work correctly, i don't think. instead, i made
it as a stand-alone that would be run once or twice a day.

watch out for the two longest lines (setting the ranges). they will
definitely wrap the text in the newsgroup reader! you will have to un-
wrap them. i wasn't sure how to break them up in the coding.
=======================
Option Explicit

Sub Ranjit()

Dim myLastRow As Long
Dim mySheet As Worksheet
Dim WS As Worksheet
Dim mySheetName As String
Dim myShtRow As Long
Dim myRange As Range
Dim myOtherRange As Range
Dim myCell As Range

Set WS = Worksheets("Master")
myLastRow = WS.Cells(20000, 1).End(xlUp).Row
Set myCell = WS.Range("a2")

Do Until myCell.Row = myLastRow
If myCell.Offset(0, 1).Value = Date Then
Set myRange = WS.Range("a" & myCell.Row & ":e" & myCell.Row)
'unwrap me
mySheetName = myCell.Text
Set mySheet = Worksheets(mySheetName)
myShtRow = mySheet.Cells(20000, 1).End(xlUp).Row + 1
Set myOtherRange = mySheet.Range("a" & myShtRow & ":e" &
myShtRow) 'unwrap me
myRange.Copy Destination:=myOtherRange
End If
Set myCell = myCell.Offset(1, 0)
Loop

End Sub
====================
hope it at least gets you started!

susan



On Jun 25, 5:35*am, Ranjit kurian
<Ranjitkur...@discussions.microsoft.com> wrote:
> Hi
>
> I have a master sheet in excel which contain all the below details as per
> sheet names('status' column are the sheet names)
>
> Status *Date * *Patient ID * * *Docter Name * * Region
> Critical * * * *6/25/2008 * * * 34567 * Suhas * * ** * * * * *IE
> Died * *6/25/2008 * * * 12345 * Pradeep * * * * * * US
>
> This master sheet is updated on daily bases, new recordes will been addedon
> daily, i need a macro so that when ever the new recordes are added to the
> master sheet , all the other sheets similutaneous need to be filled example:
>
> if the Status column is Critical then what ever details is update next to
> that column need to filled in Critical Sheet.......
>
> The macro should match the sheet name and mastersheet data , then it should
> copy the related details to that particular sheet


 
Reply With Quote
 
Susan
Guest
Posts: n/a
 
      25th Jun 2008
found one error (was skipping last line) & wrapped those 2 lines......
try this one instead.
============================
Option Explicit

Sub Ranjit()

Dim myLastRow As Long
Dim mySheet As Worksheet
Dim WS As Worksheet
Dim mySheetName As String
Dim myShtRow As Long
Dim myRange As Range
Dim myOtherRange As Range
Dim myCell As Range

Set WS = Worksheets("Master")
myLastRow = WS.Cells(20000, 1).End(xlUp).Row
Set myCell = WS.Range("a2")

Do Until myCell.Row = myLastRow + 1
If myCell.Offset(0, 1).Value = Date Then
Set myRange = WS.Range("a" & myCell.Row _
& ":e" & myCell.Row)
mySheetName = myCell.Text
Set mySheet = Worksheets(mySheetName)
myShtRow = mySheet.Cells(20000, 1).End(xlUp).Row + 1
Set myOtherRange = mySheet.Range("a" _
& myShtRow & ":e" & myShtRow)
myRange.Copy Destination:=myOtherRange
End If
Set myCell = myCell.Offset(1, 0)
Loop

End Sub
========================
susan


On Jun 25, 2:00*pm, Susan <bogenex...@aol.com> wrote:
> well, no one else has tried, so i'll give it a go. *please save your
> work before running this macro. *i did not make it an automatic
> worksheet_change as you requested, because it would be running
> constantly & would not work correctly, i don't think. *instead, i made
> it as a stand-alone that would be run once or twice a day.
>
> watch out for the two longest lines (setting the ranges). *they will
> definitely wrap the text in the newsgroup reader! *you will have to un-
> wrap them. *i wasn't sure how to break them up in the coding.
> =======================
> Option Explicit
>
> Sub Ranjit()
>
> Dim myLastRow As Long
> Dim mySheet As Worksheet
> Dim WS As Worksheet
> Dim mySheetName As String
> Dim myShtRow As Long
> Dim myRange As Range
> Dim myOtherRange As Range
> Dim myCell As Range
>
> Set WS = Worksheets("Master")
> myLastRow = WS.Cells(20000, 1).End(xlUp).Row
> Set myCell = WS.Range("a2")
>
> Do Until myCell.Row = myLastRow
> * *If myCell.Offset(0, 1).Value = Date Then
> * * * Set myRange = WS.Range("a" & myCell.Row & ":e" & myCell.Row)
> 'unwrap me
> * * * mySheetName = myCell.Text
> * * * Set mySheet = Worksheets(mySheetName)
> * * * myShtRow = mySheet.Cells(20000, 1).End(xlUp).Row + 1
> * * * Set myOtherRange = mySheet.Range("a" & myShtRow & ":e" &
> myShtRow) * 'unwrap me
> * * * myRange.Copy Destination:=myOtherRange
> * * End If
> Set myCell = myCell.Offset(1, 0)
> Loop
>
> End Sub
> ====================
> hope it at least gets you started!
>
> susan
>
> On Jun 25, 5:35*am, Ranjit kurian
>
>
>
> <Ranjitkur...@discussions.microsoft.com> wrote:
> > Hi

>
> > I have a master sheet in excel which contain all the below details as per
> > sheet names('status' column are the sheet names)

>
> > Status *Date * *Patient ID * * *Docter Name * * Region
> > Critical * * * *6/25/2008 * * * 34567 * Suhas * * * * * * * * *IE
> > Died * *6/25/2008 * * * 12345 * Pradeep * * * * ** US

>
> > This master sheet is updated on daily bases, new recordes will been added on
> > daily, i need a macro so that when ever the new recordes are added to the
> > master sheet , all the other sheets similutaneous need to be filled example:

>
> > if the Status column is Critical then what ever details is update next to
> > that column need to filled in Critical Sheet.......

>
> > The macro should match the sheet name and mastersheet data , then it should
> > copy the related details to that particular sheet- Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
Ranjit kurian
Guest
Posts: n/a
 
      26th Jun 2008
Hi Susan
Thanks for the code, but it did not meet my requirement...

Actually i have four sheets and they are 'Master', 'Under Treatment',
'Critical', 'Died'

Master sheet, is the sheet which contain all the informations as per sheet
names ('Under Treatment', 'Critical', 'Died'), and it is updated on daily
bases, my requirement starts here, as an when the master sheet is updated,
after that when i run macro the details which are given in master sheets need
to be updated to the respective sheets as per the sheet names.

For example : today if i update my master sheet only about Died details

Sheet Name: Master
Status Date Patient ID Docter Name Region
Died 6/25/2008 45677 Pradeep DK

Answer
after runing macro the above information, need to be copied from the master
sheet and put it in 'Died' Sheet

Sheet Name: Died
Status Date Patient ID Docter Name Region
Died 6/25/2008 45677 Pradeep DK

the logic here is i have 50 sheets, every day i have to copy the information
of 50 sheets from one master sheet, i just want to avoid it.

Please help me.....





"Susan" wrote:

> found one error (was skipping last line) & wrapped those 2 lines......
> try this one instead.
> ============================
> Option Explicit
>
> Sub Ranjit()
>
> Dim myLastRow As Long
> Dim mySheet As Worksheet
> Dim WS As Worksheet
> Dim mySheetName As String
> Dim myShtRow As Long
> Dim myRange As Range
> Dim myOtherRange As Range
> Dim myCell As Range
>
> Set WS = Worksheets("Master")
> myLastRow = WS.Cells(20000, 1).End(xlUp).Row
> Set myCell = WS.Range("a2")
>
> Do Until myCell.Row = myLastRow + 1
> If myCell.Offset(0, 1).Value = Date Then
> Set myRange = WS.Range("a" & myCell.Row _
> & ":e" & myCell.Row)
> mySheetName = myCell.Text
> Set mySheet = Worksheets(mySheetName)
> myShtRow = mySheet.Cells(20000, 1).End(xlUp).Row + 1
> Set myOtherRange = mySheet.Range("a" _
> & myShtRow & ":e" & myShtRow)
> myRange.Copy Destination:=myOtherRange
> End If
> Set myCell = myCell.Offset(1, 0)
> Loop
>
> End Sub
> ========================
> susan
>
>
> On Jun 25, 2:00 pm, Susan <bogenex...@aol.com> wrote:
> > well, no one else has tried, so i'll give it a go. please save your
> > work before running this macro. i did not make it an automatic
> > worksheet_change as you requested, because it would be running
> > constantly & would not work correctly, i don't think. instead, i made
> > it as a stand-alone that would be run once or twice a day.
> >
> > watch out for the two longest lines (setting the ranges). they will
> > definitely wrap the text in the newsgroup reader! you will have to un-
> > wrap them. i wasn't sure how to break them up in the coding.
> > =======================
> > Option Explicit
> >
> > Sub Ranjit()
> >
> > Dim myLastRow As Long
> > Dim mySheet As Worksheet
> > Dim WS As Worksheet
> > Dim mySheetName As String
> > Dim myShtRow As Long
> > Dim myRange As Range
> > Dim myOtherRange As Range
> > Dim myCell As Range
> >
> > Set WS = Worksheets("Master")
> > myLastRow = WS.Cells(20000, 1).End(xlUp).Row
> > Set myCell = WS.Range("a2")
> >
> > Do Until myCell.Row = myLastRow
> > If myCell.Offset(0, 1).Value = Date Then
> > Set myRange = WS.Range("a" & myCell.Row & ":e" & myCell.Row)
> > 'unwrap me
> > mySheetName = myCell.Text
> > Set mySheet = Worksheets(mySheetName)
> > myShtRow = mySheet.Cells(20000, 1).End(xlUp).Row + 1
> > Set myOtherRange = mySheet.Range("a" & myShtRow & ":e" &
> > myShtRow) 'unwrap me
> > myRange.Copy Destination:=myOtherRange
> > End If
> > Set myCell = myCell.Offset(1, 0)
> > Loop
> >
> > End Sub
> > ====================
> > hope it at least gets you started!
> >
> > susan
> >
> > On Jun 25, 5:35 am, Ranjit kurian
> >
> >
> >
> > <Ranjitkur...@discussions.microsoft.com> wrote:
> > > Hi

> >
> > > I have a master sheet in excel which contain all the below details as per
> > > sheet names('status' column are the sheet names)

> >
> > > Status Date Patient ID Docter Name Region
> > > Critical 6/25/2008 34567 Suhas IE
> > > Died 6/25/2008 12345 Pradeep US

> >
> > > This master sheet is updated on daily bases, new recordes will been added on
> > > daily, i need a macro so that when ever the new recordes are added to the
> > > master sheet , all the other sheets similutaneous need to be filled example:

> >
> > > if the Status column is Critical then what ever details is update next to
> > > that column need to filled in Critical Sheet.......

> >
> > > The macro should match the sheet name and mastersheet data , then it should
> > > copy the related details to that particular sheet- Hide quoted text -

> >
> > - Show quoted text -

>
>

 
Reply With Quote
 
Susan
Guest
Posts: n/a
 
      26th Jun 2008
this sub should work regardless of how many sheets you have...... from
what you explain the macro i wrote will do what you want; it will copy
the data from the master sheet to the sub-sheet.
but you are saying you want the information UPDATED, which is
different than just copied/listed; the same person may be on the
master sheet several days, with a different status each day, and you
only want them to appear once, under the now-correct status sheet.
if that's what you want, i'm sorry, i don't know how to do that. the
only thing i can think of is another round of macro that strips out
duplicates based on patient ID & date & just leaves the most recent
entry.
susan



On Jun 26, 8:36*am, Ranjit kurian
<Ranjitkur...@discussions.microsoft.com> wrote:
> Hi Susan
> Thanks for the code, but it did not meet my requirement...
>
> Actually i have four sheets and they are *'Master', 'Under Treatment',
> 'Critical', 'Died'
>
> Master sheet, is the sheet which contain all the informations as per sheet
> names ('Under Treatment', 'Critical', 'Died'), and it is updated on daily
> bases, my requirement starts here, as an when the master sheet is updated,
> after that when i run macro the details which are given in master sheets need
> to be updated to the respective sheets as per the sheet names.
>
> For example : today if i update my master sheet only about Died details
>
> Sheet Name: Master
> Status *Date * * Patient ID * * *Docter Name * *Region
> Died * *6/25/2008 * * * *45677 * Pradeep * * * * * * * * * * * * *DK
>
> Answer
> after runing macro the above information, need to be copied from the master
> sheet and put it in 'Died' Sheet
>
> Sheet Name: Died
> Status *Date * * Patient ID * * *Docter Name * *Region
> Died * *6/25/2008 * * * *45677 * Pradeep * * * * * * * * * * * * *DK
>
> the logic here is i have 50 sheets, every day i have to copy the information
> of 50 sheets from one master sheet, i just want to avoid it.
>
> Please help me.....
>
>
>
> "Susan" wrote:
> > found one error (was skipping last line) & wrapped those 2 lines......
> > try this one instead.
> > ============================
> > Option Explicit

>
> > Sub Ranjit()

>
> > Dim myLastRow As Long
> > Dim mySheet As Worksheet
> > Dim WS As Worksheet
> > Dim mySheetName As String
> > Dim myShtRow As Long
> > Dim myRange As Range
> > Dim myOtherRange As Range
> > Dim myCell As Range

>
> > Set WS = Worksheets("Master")
> > myLastRow = WS.Cells(20000, 1).End(xlUp).Row
> > Set myCell = WS.Range("a2")

>
> > Do Until myCell.Row = myLastRow + 1
> > * *If myCell.Offset(0, 1).Value = Date Then
> > * * * Set myRange = WS.Range("a" & myCell.Row _
> > * * * * *& ":e" & myCell.Row)
> > * * * mySheetName = myCell.Text
> > * * * Set mySheet = Worksheets(mySheetName)
> > * * * myShtRow = mySheet.Cells(20000, 1).End(xlUp).Row + 1
> > * * * Set myOtherRange = mySheet.Range("a" _
> > * * * * *& myShtRow & ":e" & myShtRow)
> > * * * myRange.Copy Destination:=myOtherRange
> > * * End If
> > Set myCell = myCell.Offset(1, 0)
> > Loop

>
> > End Sub
> > ========================
> > susan

>
> > On Jun 25, 2:00 pm, Susan <bogenex...@aol.com> wrote:
> > > well, no one else has tried, so i'll give it a go. *please save your
> > > work before running this macro. *i did not make it an automatic
> > > worksheet_change as you requested, because it would be running
> > > constantly & would not work correctly, i don't think. *instead, i made
> > > it as a stand-alone that would be run once or twice a day.

>
> > > watch out for the two longest lines (setting the ranges). *they will
> > > definitely wrap the text in the newsgroup reader! *you will have toun-
> > > wrap them. *i wasn't sure how to break them up in the coding.
> > > =======================
> > > Option Explicit

>
> > > Sub Ranjit()

>
> > > Dim myLastRow As Long
> > > Dim mySheet As Worksheet
> > > Dim WS As Worksheet
> > > Dim mySheetName As String
> > > Dim myShtRow As Long
> > > Dim myRange As Range
> > > Dim myOtherRange As Range
> > > Dim myCell As Range

>
> > > Set WS = Worksheets("Master")
> > > myLastRow = WS.Cells(20000, 1).End(xlUp).Row
> > > Set myCell = WS.Range("a2")

>
> > > Do Until myCell.Row = myLastRow
> > > * *If myCell.Offset(0, 1).Value = Date Then
> > > * * * Set myRange = WS.Range("a" & myCell.Row & ":e" & myCell..Row)
> > > 'unwrap me
> > > * * * mySheetName = myCell.Text
> > > * * * Set mySheet = Worksheets(mySheetName)
> > > * * * myShtRow = mySheet.Cells(20000, 1).End(xlUp).Row + 1
> > > * * * Set myOtherRange = mySheet.Range("a" & myShtRow & ":e" &
> > > myShtRow) * 'unwrap me
> > > * * * myRange.Copy Destination:=myOtherRange
> > > * * End If
> > > Set myCell = myCell.Offset(1, 0)
> > > Loop

>
> > > End Sub
> > > ====================
> > > hope it at least gets you started!
> > >
> > > susan

>
> > > On Jun 25, 5:35 am, Ranjit kurian

>
> > > <Ranjitkur...@discussions.microsoft.com> wrote:
> > > > Hi

>
> > > > I have a master sheet in excel which contain all the below details as per
> > > > sheet names('status' column are the sheet names)

>
> > > > Status *Date * *Patient ID * * *Docter Name * * Region
> > > > Critical * * * *6/25/2008 * * * 34567 * Suhas * * * * * * * * *IE
> > > > Died * *6/25/2008 * * * 12345 * Pradeep * * * ** * US

>
> > > > This master sheet is updated on daily bases, new recordes will beenadded on
> > > > daily, i need a macro so that when ever the new recordes are added to the
> > > > master sheet , all the other sheets similutaneous need to be filledexample:

>
> > > > if the Status column is Critical then what ever details is update next to
> > > > that column need to filled in Critical Sheet.......

>
> > > > The macro should match the sheet name and mastersheet data , then it should
> > > > copy the related details to that particular sheet- Hide quoted text-

>
> > > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -


 
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
Excel 2007 help Cell value = x then row data is copied to a new sheet Baggy12 Webmaster / Programming 0 15th Sep 2010 12:41 PM
Paste copied data to specified sheet based on range - variable iss fishy Microsoft Excel Programming 6 1st Apr 2010 02:00 PM
how to update a worksheet and have data copied to another sheet? tsuriman3 Microsoft Excel Worksheet Functions 2 4th Jan 2008 01:34 AM
Combobox data accidentally copied on different sheet BenD Microsoft Excel Programming 0 18th Apr 2005 09:47 PM
Copied empty cells, give sorting problem in Data sheet Ruud Microsoft Excel Programming 0 16th Sep 2004 04:44 AM


Features
 

Advertising
 

Newsgroups
 


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