+ Reply to Thread
Results 1 to 9 of 9

Copy Data by month to table using Inputbox with Add or Delete Row

  1. #1
    Registered User
    Join Date
    11-14-2022
    Location
    india
    MS-Off Ver
    2010, 2007, 2016
    Posts
    3

    Question Copy Data by month to table using Inputbox with Add or Delete Row

    Hello,

    Please help me to copy data from my Sheet (Sheet Name: WrkingSheet) and Paste to TablebyMonth in another sheet (Sheet Name: Diff) (Book12.zip attached here). Month name will provide in Inputbox, and acording to month provided, data of that particular month will go in the Table of that Month.

    I have added the code in workbook but this is pasting data in month name sheet.

    I have tried code but it is paste data into sheet with month name. (copy data using inputbox based on month) I want to paste data in same sheet but different tables. And require to overwrite data if any old/other data present in that cell with add or delete row as per entries.


    Please check.


    Thank You.



    This question also posted here:
    mrexcel.com/board/threads/copy-data-by-month-to-table-using-inputbox-with-add-or-delete-row.1221874/
    forum.ozgrid.com/forum/index.php?thread/1232681-copy-data-by-month-to-table-using-inputbox-with-add-or-delete-row/&postID=1258386#post1258386
    msofficeforums.com/171677-post1.html
    chandoo.org/forum/threads/copy-data-by-month-to-table-using-inputbox-with-add-or-delete-row.49812/
    Attached Files Attached Files
    Last edited by CemHyur; 11-14-2022 at 06:05 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Copy Data by month to table using Inputbox with Add or Delete Row

    Hello. I show you a way to do it from a "model" range:

    PHP Code: 
    Sub Traspasar_Info()
    Dim aQ&, i&, Dkey$, mCell As RangeR&, tbl
    Dim mMin 
    As DatemMax As DateAs Date

    With Sheet1
      
    If .Cells(4"b") = "" Then End
      
      With 
    .Range("b4", .Range("b3").End(xlDown))
        
    mMin Application.Min(.Cells): mMin mMin Day(mMin) + 1
        mMax 
    Application.Max(.Cells): mMax mMax Day(mMax) + 1
        a 
    = .Resize(, 3).ValueUBound(a)
      
    End With
      Set D 
    CreateObject("Scripting.Dictionary")
      
      For 
    1 To Q
        key 
    Format(a(i1), "mm_yyyy")
        If 
    D.Exists(keyThen
          R 
    D(key)(0): tbl D(key)(1)
          
    tbl(R1) = a(i1): tbl(R2) = a(i2): tbl(R3) = a(i3)
          
    D(key) = Array(Rtbl)
        Else
          
    ReDim tbl(1 To Q1 To 3)
          
    tbl(11) = a(i1): tbl(12) = a(i2): tbl(13) = a(i3)
          
    D(key) = Array(1tbl)
        
    End If
      
    Next
    End With

    With Sheet2
      
    .Rows("1:4").Hidden True
      
    .Range("f7", .Cells(Rows.Count"f").End(xlUp)).Offset(1, -1).Resize(, 7).Delete xlShiftUp
      
      f 
    mMin
      
    Do
        
    key Format(f"mm_yyyy")
        If 
    D.Exists(keyThen
          Set mCell 
    = .Cells(Rows.Count"f").End(xlUp).Offset(2, -1)
          
    Range("Diff_Model").Copy mCell
          mCell
    .Offset(2).Range("a1:g" D(key)(0) - 1).Insert xlShiftDown
          mCell 
    f
          mCell
    (2).Resize(D(key)(0), 3) = D(key)(1)
        
    End If
        
    DateAdd("m"1f)
      
    Loop While <= mMax
      
    .Activate
    End With
    End Sub 
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    11-14-2022
    Location
    india
    MS-Off Ver
    2010, 2007, 2016
    Posts
    3

    Exclamation Re: Copy Data by month to table using Inputbox with Add or Delete Row

    First of all Thank you very much for your effort.

    Second thing is I didn't understand code.

    It's working, but sometime giving Error in this line.
    Please Login or Register  to view this content.
    and where to add other months? I have tried to add but not working.

    Thanks.

  4. #4
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Copy Data by month to table using Inputbox with Add or Delete Row

    You are right. Then:

    PHP Code: 
    Rem >Replaces:
      
    mCell.Offset(2).Range("a1:g" D(key)(0) - 1).Insert xlShiftDown

    Rem 
    >for this other:
      If 
    D(key)(0) > 1 Then mCell.Offset(2).Range("a1:g" D(key)(0) - 1).Insert xlShiftDown 

  5. #5
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Copy Data by month to table using Inputbox with Add or Delete Row

    The variant I am attaching now may be better understood by you because it does the same thing as the previous variant but without using a Dictionary.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Copy Data by month to table using Inputbox with Add or Delete Row


    Hi beyond Excel,

    it seems solved on another forum …

  7. #7
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Copy Data by month to table using Inputbox with Add or Delete Row

    Quote Originally Posted by Marc L View Post

    Hi beyond Excel,

    it seems solved on another forum …
    Too bad!... (for the lack of gratitude).

  8. #8
    Registered User
    Join Date
    11-14-2022
    Location
    india
    MS-Off Ver
    2010, 2007, 2016
    Posts
    3

    Re: Copy Data by month to table using Inputbox with Add or Delete Row

    Hi Beyond Excel,

    Thank you for your efforts and Sorry for the late reply.

    Code Working as require, but the thing is, It is creating Tables in new sheet. But I have already created Blanks Table in Sheet2 (Diff Sheet). So If there is no data in any month then it will keep it blank (it is ok if It'll create Table in Sheet2, but need to also create blank if no any data in particular month). So if possible that way? And also month will start from April ('cause we are counting year from April to March).

    Thank You Very Much.

  9. #9
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Copy Data by month to table using Inputbox with Add or Delete Row

    In this Forum it is customary to thank the help received by adding reputation (click on *) at the bottom right of the messages that have helped you solve your problem.

+ 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] copy data from sheet to another based on name by inputbox
    By ABDELFATTA in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-19-2020, 09:39 AM
  2. [SOLVED] adjusting code copy data by using inputbox
    By ABDELFATTA in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2020, 01:42 PM
  3. [SOLVED] Copy paste data from table to another table then delete data without losing formulas
    By dps9460 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2019, 03:14 AM
  4. [SOLVED] VBA- Using inputbox to filter and copy data
    By Heisenberg_2 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 05-07-2016, 02:56 AM
  5. [SOLVED] Inputbox with file is opened with input data verified with table
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-27-2013, 06:47 PM
  6. [SOLVED] Increment cell and copy data down from InputBox
    By Nu2Java in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-22-2013, 01:49 PM
  7. Using inputbox in excel to insert data into sql table
    By hvisa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-15-2009, 01:31 PM

Tags for this Thread

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