![]() |
need help w/ macro prompting with info and pasting the info based on user input
I need help with a macro. I am showing the sample sheets below. The
Macro needs to go to SHEET 2 and copy the amounts and paste into SHEET 1. Now into more detail. The info in SHEET 2 might contain some hidden rows which should be omitted. It should go through all the visible rows (besides the first one) and display an input box for each row. The input box should display the "amount" and "Description" column info for the row (needs to be done one by one for each visible row). The input box would be prompting me for input. The input decides into which ROW in SHEET 1 the AMOUNT info (not the description) is pasted. The macro should paste automatically into the column in SHEET 1 based on the "Dacct" info from SHEET 2. The user only picks the row and the macro picks the column based on matching the "Dacct" numbers in both sheets. Let's make an example based on the first row (after header) . I need the macro to paste 500.5 from SHEET 2 into "Jan" row and "15000" column in SHEET 1. An input box would pop up showing me : "Amount: 500.5 Description: good" . It would be prompting me: "Please choose date: " The input would decide into which row in SHEET 1 the 500.5 is pasted. The macro would then decide based on the "Dacct" value in that row in SHEET 2 which column in SHEET 1 to pick. The input answer for the prompt would be 1-12 for the rows "Jan-Dec". "P" would be the input for the "Previous Year" row. I do not even know where to begin... Really hope somebody can help me on this one. I am not a programmer so anything can help. SHEET 1: Previous Year DAcct 15000 16000 17000 Jan 500.5 Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec SHEET 2: Prod# Asset# Amount Dacct Type Description F1550 B55 500.5 15000 Lunch good F1560 B55 600.3 15000 Lunch bad F1570 B55 800 15000 Lunch not so bad F1580 B55 98 15000 Lunch pretty good F1660 B55 789 16000 Auto pretty good F1670 B55 4564 16000 Auto cool F1690 B55 785 17000 Loca nasty F1700 B55 7227 17000 Loca terrific |
need help w/ macro prompting with info and pasting the info based on user input
Actually sheet 1 would look as follows with "Previous Year" below
"Dacct" SHEET 1: DAcct 15000 16000 17000 Previous Year Jan 500.5 Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec |
need help w/ macro prompting with info and pasting the info based on user input
At least some possible functions and codes I can edit to fit it into
the scheme of this Macro I need. I just looked and I do not even know where to start. |
need help w/ macro prompting with info and pasting the info based on user input
drgka55 wrote: At least some possible functions and codes I can edit to fit it into the scheme of this Macro I need. I just looked and I do not even know where to start. I have few questions. 1/ Not sure what the relevance of entering the P is.? Do you what to seperate the data into different years...if is there a separate table on sheet 1 for each year. 2/ What do you if the there are multiple value for the same DAACT for the same month? do you sum them under the DAACT for that month?? |
need help w/ macro prompting with info and pasting the info based on user input
I have few questions. 1/ Not sure what the relevance of entering the P is.? Do you what to seperate the data into different years...if is there a separate table on sheet 1 for each year. 2/ What do you if the there are multiple value for the same DAACT for the same month? do you sum them under the DAACT for that month?? 1. The P is for the "Previous Year" row in SHEET1. We can say that it is row 10. I was counting on creating an "answer key" for each of the rows I would want to paste the information into. SHEET1 as displayed shows 12 months of the year and 1 row ("prior year") for everything else. 2. I want to actually paste the values and ADD them example: if the month already contains values for a certain account (DACCT) then I want to add to it (=500 exists ,needs to add 450, then make it =500+450 or it would be more like =(500)+450 when excel does the paste ADD . I need to keep each amount separate and just add to them new values from SHEET2 according to the criteria. |
need help w/ macro prompting with info and pasting the info based on user input
I am working on something for you..If your email as shown works here. (
if not email me you email address.).I will email what I will have to do this. (50% done now). I |
need help w/ macro prompting with info and pasting the info based on user input
Ok try this Make userform ...I used userform1 add 3 labels (1,2,3)and 2 comboboxes (1 &2) and 2 command buttons command button 1 is row move to the next row (below) and gets the entrys. command buton 2 enter the data to sheet1 paste the code below. assumptions: on sheet 2 the amount is column 3 (C) , the Dacct in col 4 (D) and 'status' (good/bad) in col 6 (F). and the first entry is on row 3 The data output goes in sheet 1 previous year row 10 jan this year starts at row 12 and so on down 15000 data goes in column 3 (C) 16000 data goes inis column 4 (D) 17000 data goes in column 5 (E) Numbers are added as you requested. Anyway code is below If you have any questions let me know ------------------------------------------------- Private Sub CommandButton1_Click() Cells(ActiveCell.Row + 1, 3).Select ' moves to the next entry Call refresh ' get data from sheet 2 End Sub Private Sub CommandButton2_Click() ' write data to sheet 1 for current entry Call populate End Sub Sub refresh() Sheet2.Activate Cells(ActiveCell.Row, 3).Select Label1.Caption = ActiveCell.Value Label2.Caption = ActiveCell.Offset(0, 1).Value Label3.Caption = ActiveCell.Offset(0, 3).Value With ComboBox1 ' populate month combo box ..Clear ..AddItem "Jan" ..AddItem "Feb" ..AddItem "Mar" ..AddItem "Apr" ..AddItem "May" ..AddItem "Jun" ..AddItem "Jul" ..AddItem "Aug" ..AddItem "Sep" ..AddItem "Oct" ..AddItem "Nov" ..AddItem "Dec" ..ListIndex = 0 End With With ComboBox2 ..Clear ..AddItem "Current Year" ..AddItem "Previous Year" ..ListIndex = 0 End With End Sub Sub populate() If ComboBox2.ListIndex = 1 Then ' is the entry for the previous year If UserForm1.Label2.Caption = "15000" Then Sheet1.Cells(10, 3).Value = Sheet1.Cells(10, 3).Value + Val(UserForm1.Label1.Caption) If UserForm1.Label2.Caption = "16000" Then Sheet1.Cells(10, 4).Value = Sheet1.Cells(10, 4).Value + Val(UserForm1.Label1.Caption) If UserForm1.Label2.Caption = "17000" Then Sheet1.Cells(10, 5).Value = Sheet1.Cells(10, 5).Value + Val(UserForm1.Label1.Caption) Else ' for the current year Dim i As Integer i = 12 + ComboBox1.ListIndex ' for the month If UserForm1.Label2.Caption = "15000" Then Sheet1.Cells(i, 3).Value = Sheet1.Cells(i, 3).Value + Val(UserForm1.Label1.Caption) If UserForm1.Label2.Caption = "16000" Then Sheet1.Cells(i, 4).Value = Sheet1.Cells(i, 4).Value + Val(UserForm1.Label1.Caption) If UserForm1.Label2.Caption = "17000" Then Sheet1.Cells(i, 5).Value = Sheet1.Cells(i, 5).Value + Val(UserForm1.Label1.Caption) End If End Sub Private Sub UserForm_Initialize() Sheet2.Activate Sheet2.Cells(3, 3).Select ' starts at the amount in the third row, 3rd column Call refresh End Sub |
need help w/ macro prompting with info and pasting the info based on user input
stevebriz thank you very much for your time and effort on this. I have not tried it out yet but I will test the code asap and get back to you. |
need help w/ macro prompting with info and pasting the info based on user input
I emailed you the latest changes you want. |
All times are GMT +1. The time now is 06:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com