View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Susan Susan is offline
external usenet poster
 
Posts: 1,117
Default Data need to be copied as per sheet name

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 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



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 -