Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Parick Molloy i am Tiya Shah you have given reply to my problem but still
i have problem. My problem is it's runing and crating new worksheet with date name but if i add new data in same date and than i run the prog. I should copy only new data but this prog. copy old data also in new rows i just want to add only new data if i run prg. again. I am pasting code code is here.... Option Explicit Sub PopulateData() ' assume input file has a worksheet called Data Dim ws As Worksheet Set ws = Worksheets("data") Dim rw As Long ' index for reading data Dim targetrow As Long ' row for writing data Dim wsTarget As Worksheet ' where data is to go Dim Col As Long ' used for setting pmt or rct column rw = 2 'assumes first row is heading Do Until ws.Cells(rw, 1).Value = "" If InStr(UCase(Cells(rw, 2).Value), "REC") 0 Then Col = 4 Else Col = 1 End If Set wsTarget = safeSheet(Format$(ws.Cells(rw, 1).Value, "dd-mmmm")) targetrow = wsTarget.Cells(56000, Col).End(xlUp).Row + 1 With wsTarget With .Range(.Cells(targetrow, Col), .Cells(targetrow, Col + 2)) .Value = ws.Range(ws.Cells(rw, 2), ws.Cells(rw, 4)).Value End With End With rw = rw + 1 Loop End Sub Private Function safeSheet(sSheetName As String) As Worksheet On Error Resume Next Set safeSheet = Worksheets(sSheetName) If Err.Number < 0 Then Err.Clear Set safeSheet = ThisWorkbook.Worksheets.Add safeSheet.Name = sSheetName If Err.Number < 0 Then GoTo trap End If On Error GoTo 0 Exit Function trap: MsgBox Err.Description, , "Error Adding Worksheet:" & sSheetName On Error GoTo 0 End Function pls reply me or if possible for you to than i mail you my file so pls give your e-mail ID. Thanks Regards Tiya |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
fao patrick molloy | Excel Programming | |||
No need to reply!! | Excel Programming | |||
visual basic macro reply to P Molloy | Excel Programming | |||
Reply to Tom | Excel Programming | |||
Reply to Tom | Excel Programming |