Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Somewhat complex code to copy data from one sheet to another
The code is in the "Groceries Needed" sheet module.
First InputBox... myMeal = a header in sheet named "Groceries Needed". Second InputBox... ColmyMeal = the column of myMeal in sheet "Groceries Needed". Case "Chili" = Chili is the header of column D in sheet named "Recipes". User enters Chili in first InputBox. User enters B in second InputBox. Want to copy the Chili ingredients listed in column D of sheet "Recipes" to column B of sheet "Groceries Needed". However, next week Chili may be in column F of sheet "Groceries Needed" but the ingredients for Chili will always be in column D sheet "Recipes". Code as is returns Case Else. Thanks. Howard Option Explicit Option Compare Text Sub Graba_Grub_Dub() Dim myMeal As String Dim ColmyMeal As String myMeal = InputBox(Prompt:="What Meal...?", _ Title:="DINE TIME", Default:="Your Meal here") 'MsgBox myMeal ColmyMeal = InputBox(Prompt:="What Column...?", _ Title:="The Column", Default:="The Meal Column Here") 'MsgBox ColmyMeal If myMeal = "Your Name here" Or myMeal = vbNullString Then Exit Sub If ColmyMeal = "The Meal Column Here" Or ColmyMeal = vbNullString Then Exit Sub Select Case "myMeal" Case "Chili" Sheets("Recipe").Range("D3:D" & Range("D" & Rows.Count) _ .End(xlUp).Row).Copy Sheets("Groceries Needed") _ .Cells(Sheets("Groceries Needed") _ .Rows.Count, "ColmyMeal").End(xlUp).Offset(1, 0) Case Else MsgBox "NaDa Good myMeal" End Select End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Complex Compare Values, and Copy/Paste if in One Sheet but Not Oth | Excel Programming | |||
Copy and paste subtotals-complex data range error | Excel Discussion (Misc queries) | |||
Complex Question. Index/Match then Copy/Paste to Summary Sheet | Excel Programming | |||
Copy all data into one sheet and insert origin data... code amend... | Excel Programming | |||
How to Copy Data from on field to another? Complex? | Excel Discussion (Misc queries) |