+ Reply to Thread
Results 1 to 5 of 5

Moving data between worksheets ...

  1. #1
    Ian Edmont
    Guest

    Moving data between worksheets ...

    Hi,

    Wonder if someone can help me please?

    I have a sheet in a workbook called "Sheet1" (please see
    www.iedmont.blogspot.com/) and what I am trying to do is move all rows
    that contain a date into a separate sheet within the workbook called
    "JanArchive".

    "JanArchive" already contains archived entries and I would like to
    combine the data from "Sheet1" with the data from "JanArchive".

    Can anyone offer any suggestions how to do this please?

    Many thanks for your time.

    Ian Edmont.


  2. #2
    Martin Fishlock
    Guest

    RE: Moving data between worksheets ...

    Try this:

    Option Explicit

    Const csz_dst_sheet As String = "JanArchive"
    Const csz_src_sheet As String = "Sheet1"

    Sub movedata()
    Dim wsd As Worksheet 'dst worksheet
    Dim wss As Worksheet 'src worksheet
    Dim rd As Long ' dst row
    Dim rs As Long ' src row

    Set wsd = ActiveWorkbook.Worksheets(csz_dst_sheet)
    Set wss = ActiveWorkbook.Worksheets(csz_src_sheet)

    'find last row on dst
    rd = 2
    While wsd.Cells(rd, 1) <> ""
    rd = rd + 1
    Wend

    rs = 2
    While wss.Cells(rs, 1) <> ""
    If wss.Cells(rs, 2) <> "" Then
    wss.Rows(rs).Copy Destination:=wsd.Rows(rd)
    rd = rd + 1
    End If
    rs = rs + 1
    Wend
    Set wss = Nothing
    Set wsd = Nothing
    End Sub
    '------------
    --
    HTHs Martin


    "Ian Edmont" wrote:

    > Hi,
    >
    > Wonder if someone can help me please?
    >
    > I have a sheet in a workbook called "Sheet1" (please see
    > www.iedmont.blogspot.com/) and what I am trying to do is move all rows
    > that contain a date into a separate sheet within the workbook called
    > "JanArchive".
    >
    > "JanArchive" already contains archived entries and I would like to
    > combine the data from "Sheet1" with the data from "JanArchive".
    >
    > Can anyone offer any suggestions how to do this please?
    >
    > Many thanks for your time.
    >
    > Ian Edmont.
    >
    >


  3. #3
    Ian Edmont
    Guest

    Re: Moving data between worksheets ...

    Thanks for that Martin, it worked fine however it leaves the rows on
    Sheet1 in place.

    Is there a way to delete the rows from Sheet1 after they have been
    transferred to JanArchive?

    Many thanks.

    Ian Edmont.


    Martin Fishlock wrote:

    > Try this:
    >
    > Option Explicit
    >
    > Const csz_dst_sheet As String = "JanArchive"
    > Const csz_src_sheet As String = "Sheet1"
    >
    > Sub movedata()
    > Dim wsd As Worksheet 'dst worksheet
    > Dim wss As Worksheet 'src worksheet
    > Dim rd As Long ' dst row
    > Dim rs As Long ' src row
    >
    > Set wsd = ActiveWorkbook.Worksheets(csz_dst_sheet)
    > Set wss = ActiveWorkbook.Worksheets(csz_src_sheet)
    >
    > 'find last row on dst
    > rd = 2
    > While wsd.Cells(rd, 1) <> ""
    > rd = rd + 1
    > Wend
    >
    > rs = 2
    > While wss.Cells(rs, 1) <> ""
    > If wss.Cells(rs, 2) <> "" Then
    > wss.Rows(rs).Copy Destination:=wsd.Rows(rd)
    > rd = rd + 1
    > End If
    > rs = rs + 1
    > Wend
    > Set wss = Nothing
    > Set wsd = Nothing
    > End Sub
    > '------------
    > --
    > HTHs Martin
    >
    >
    > "Ian Edmont" wrote:
    >
    > > Hi,
    > >
    > > Wonder if someone can help me please?
    > >
    > > I have a sheet in a workbook called "Sheet1" (please see
    > > www.iedmont.blogspot.com/) and what I am trying to do is move all rows
    > > that contain a date into a separate sheet within the workbook called
    > > "JanArchive".
    > >
    > > "JanArchive" already contains archived entries and I would like to
    > > combine the data from "Sheet1" with the data from "JanArchive".
    > >
    > > Can anyone offer any suggestions how to do this please?
    > >
    > > Many thanks for your time.
    > >
    > > Ian Edmont.
    > >
    > >



  4. #4
    Martin Fishlock
    Guest

    Re: Moving data between worksheets ...

    Ian on the second loop modify it as thus:

    rs = 2
    While wss.Cells(rs, 1) <> ""
    If wss.Cells(rs, 2) <> "" Then
    wss.Rows(rs).Copy Destination:=wsd.Rows(rd)
    wss.rows(rs).Delete
    rd = rd + 1
    else
    rs = rs + 1
    End If
    Wend

    --
    HTHs Martin


    "Ian Edmont" wrote:

    > Thanks for that Martin, it worked fine however it leaves the rows on
    > Sheet1 in place.
    >
    > Is there a way to delete the rows from Sheet1 after they have been
    > transferred to JanArchive?
    >
    > Many thanks.
    >
    > Ian Edmont.
    >
    >
    > Martin Fishlock wrote:
    >
    > > Try this:
    > >
    > > Option Explicit
    > >
    > > Const csz_dst_sheet As String = "JanArchive"
    > > Const csz_src_sheet As String = "Sheet1"
    > >
    > > Sub movedata()
    > > Dim wsd As Worksheet 'dst worksheet
    > > Dim wss As Worksheet 'src worksheet
    > > Dim rd As Long ' dst row
    > > Dim rs As Long ' src row
    > >
    > > Set wsd = ActiveWorkbook.Worksheets(csz_dst_sheet)
    > > Set wss = ActiveWorkbook.Worksheets(csz_src_sheet)
    > >
    > > 'find last row on dst
    > > rd = 2
    > > While wsd.Cells(rd, 1) <> ""
    > > rd = rd + 1
    > > Wend
    > >
    > > rs = 2
    > > While wss.Cells(rs, 1) <> ""
    > > If wss.Cells(rs, 2) <> "" Then
    > > wss.Rows(rs).Copy Destination:=wsd.Rows(rd)
    > > rd = rd + 1
    > > End If
    > > rs = rs + 1
    > > Wend
    > > Set wss = Nothing
    > > Set wsd = Nothing
    > > End Sub
    > > '------------
    > > --
    > > HTHs Martin
    > >
    > >
    > > "Ian Edmont" wrote:
    > >
    > > > Hi,
    > > >
    > > > Wonder if someone can help me please?
    > > >
    > > > I have a sheet in a workbook called "Sheet1" (please see
    > > > www.iedmont.blogspot.com/) and what I am trying to do is move all rows
    > > > that contain a date into a separate sheet within the workbook called
    > > > "JanArchive".
    > > >
    > > > "JanArchive" already contains archived entries and I would like to
    > > > combine the data from "Sheet1" with the data from "JanArchive".
    > > >
    > > > Can anyone offer any suggestions how to do this please?
    > > >
    > > > Many thanks for your time.
    > > >
    > > > Ian Edmont.
    > > >
    > > >

    >
    >


  5. #5
    Ian Edmont
    Guest

    Re: Moving data between worksheets ...

    Thanks very much Martin. Exactly what I needed.

    Ian Edmont.


    Martin Fishlock wrote:

    > Ian on the second loop modify it as thus:
    >
    > rs = 2
    > While wss.Cells(rs, 1) <> ""
    > If wss.Cells(rs, 2) <> "" Then
    > wss.Rows(rs).Copy Destination:=wsd.Rows(rd)
    > wss.rows(rs).Delete
    > rd = rd + 1
    > else
    > rs = rs + 1
    > End If
    > Wend
    >
    > --
    > HTHs Martin
    >
    >
    > "Ian Edmont" wrote:
    >
    > > Thanks for that Martin, it worked fine however it leaves the rows on
    > > Sheet1 in place.
    > >
    > > Is there a way to delete the rows from Sheet1 after they have been
    > > transferred to JanArchive?
    > >
    > > Many thanks.
    > >
    > > Ian Edmont.
    > >
    > >
    > > Martin Fishlock wrote:
    > >
    > > > Try this:
    > > >
    > > > Option Explicit
    > > >
    > > > Const csz_dst_sheet As String = "JanArchive"
    > > > Const csz_src_sheet As String = "Sheet1"
    > > >
    > > > Sub movedata()
    > > > Dim wsd As Worksheet 'dst worksheet
    > > > Dim wss As Worksheet 'src worksheet
    > > > Dim rd As Long ' dst row
    > > > Dim rs As Long ' src row
    > > >
    > > > Set wsd = ActiveWorkbook.Worksheets(csz_dst_sheet)
    > > > Set wss = ActiveWorkbook.Worksheets(csz_src_sheet)
    > > >
    > > > 'find last row on dst
    > > > rd = 2
    > > > While wsd.Cells(rd, 1) <> ""
    > > > rd = rd + 1
    > > > Wend
    > > >
    > > > rs = 2
    > > > While wss.Cells(rs, 1) <> ""
    > > > If wss.Cells(rs, 2) <> "" Then
    > > > wss.Rows(rs).Copy Destination:=wsd.Rows(rd)
    > > > rd = rd + 1
    > > > End If
    > > > rs = rs + 1
    > > > Wend
    > > > Set wss = Nothing
    > > > Set wsd = Nothing
    > > > End Sub
    > > > '------------
    > > > --
    > > > HTHs Martin
    > > >
    > > >
    > > > "Ian Edmont" wrote:
    > > >
    > > > > Hi,
    > > > >
    > > > > Wonder if someone can help me please?
    > > > >
    > > > > I have a sheet in a workbook called "Sheet1" (please see
    > > > > www.iedmont.blogspot.com/) and what I am trying to do is move all rows
    > > > > that contain a date into a separate sheet within the workbook called
    > > > > "JanArchive".
    > > > >
    > > > > "JanArchive" already contains archived entries and I would like to
    > > > > combine the data from "Sheet1" with the data from "JanArchive".
    > > > >
    > > > > Can anyone offer any suggestions how to do this please?
    > > > >
    > > > > Many thanks for your time.
    > > > >
    > > > > Ian Edmont.
    > > > >
    > > > >

    > >
    > >



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1