+ Reply to Thread
Results 1 to 7 of 7

Transfer Data from one sheet to many with VBA

  1. #1
    Registered User
    Join Date
    04-27-2020
    Location
    pakistan
    MS-Off Ver
    2010
    Posts
    4

    Transfer Data from one sheet to many with VBA

    Hi
    I am new to VBA for excel and I am trying to transfer data from master sheet(Data Entry) which contains expenses for different dates and for every date I have a separate sheet where I want to transfer expenses from master sheet named "Data Entry". the problem with my code is that when I transfer Column B & C amount and description from master sheet to destination sheet it transfer data to column A & B but when I want to change code for destination as column B and C in destination sheet it run for only one entry and then left the all others, I have lot of destination sheets and lot of entries for every sheet please help me in solving keeping my format for sheets in consideration. I am attaching the VBA code as well as Snaps of my sheet.



    My VBA code is as follow



    Sub copyPasteData()

    Dim strSourceSheet As String
    Dim strDestinationSheet As String
    Dim lastRow As Long

    strSourceSheet = "Data entry"

    Sheets(strSourceSheet).Visible = True
    Sheets(strSourceSheet).Select

    Range("B2").Select
    Do While ActiveCell.Value <> ""
    strDestinationSheet = ActiveCell.Value
    ActiveCell.Offset(0, 1).Resize(1, 2).Select
    Selection.Copy
    Sheets(strDestinationSheet).Visible = True
    Sheets(strDestinationSheet).Select
    lastRow = LastRowInOneColumn("A")
    Cells(lastRow + 1, 1).Select
    Selection.PasteSpecial xlPasteAll
    Application.CutCopyMode = False
    Sheets(strSourceSheet).Select
    ActiveCell.Offset(0, -1).Select
    ActiveCell.Offset(1, 0).Select
    Loop
    End Sub

    Public Function LastRowInOneColumn(col)
    'Find the last used row in a Column: column A in this example

    Dim lastRow As Long
    With ActiveSheet
    lastRow = .Cells(.Rows.Count, col).End(xlUp).Row
    End With
    LastRowInOneColumn = lastRow
    End Function
    Attached Images Attached Images

  2. #2
    Registered User
    Join Date
    04-27-2020
    Location
    pakistan
    MS-Off Ver
    2010
    Posts
    4

    Re: Transfer Data from one sheet to many with VBA

    This is the Workbook I am working with

  3. #3
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Transfer Data from one sheet to many with VBA

    Hello Atif,

    The attached file doesn't look like the pictures posted. Can you make sure you attach the correct file

  4. #4
    Registered User
    Join Date
    04-27-2020
    Location
    pakistan
    MS-Off Ver
    2010
    Posts
    4

    Re: Transfer Data from one sheet to many with VBA

    Sorry Dear Nankw83,
    you are correct I have attached the wrong file this is the actual files which is attached herewith
    thanks in anticipation
    Attached Files Attached Files

  5. #5
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Transfer Data from one sheet to many with VBA

    This is a revised code, try it out

    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-27-2020
    Location
    pakistan
    MS-Off Ver
    2010
    Posts
    4

    Re: Transfer Data from one sheet to many with VBA

    Dear nankw83
    Thank You Very Much That's what I was looking for
    many thanks

  7. #7
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Transfer Data from one sheet to many with VBA

    Glad to help … Please mark this thread as solved by selecting Thread Tools from the menu link above & add to the reputation(s) of those who helped

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Range - End if without block if error. merging sheet to sheet data transfer (help)
    By COURTTROOPER in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-18-2017, 07:09 PM
  2. [SOLVED] Issue regarding recorded Macro to transfer data from Input sheet to Storage sheet
    By Hirad001 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-29-2015, 04:26 PM
  3. Replies: 5
    Last Post: 12-30-2014, 12:41 PM
  4. Transfer data from input sheet to data sheet by using command button
    By vinh1985 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-17-2014, 12:17 AM
  5. Replies: 5
    Last Post: 02-09-2014, 08:29 PM
  6. How to transfer data from a daily input sheet to a separate monthly total sheet
    By Jcooper71 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2014, 02:37 PM
  7. Replies: 1
    Last Post: 02-13-2013, 01:32 PM

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