Copy Data To Worksheet 1 - Need Data Worksheet 2 To Become Blank

%3CLINGO-SUB%20id%3D%22lingo-sub-1419117%22%20slang%3D%22en-US%22%3ECopy%20Data%20To%20Worksheet%201%20-%20Need%20Data%20Worksheet%202%20To%20Become%20Blank%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1419117%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20the%20below%20formula%20to%20copy%20the%20date%20from%20worksheet2%20to%20worksheet1.%20It%20is%20working%20as%20it%20should%20(no%20date%20appears%20on%20worksheet1%20until%20a%20date%20is%20entered%20on%20worksheet2.%20Once%20this%20occurs%2C%20the%20order%20on%20worksheet1%20is%20closed%20and%20the%20order%20on%20worksheet2%20disappears.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DIF(Completed!%24M%244%3D%22%22%2C%22%22%2CCompleted!%24M%244)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20problem%20I%20need%20help%20with%20is%20%22once%20I%20have%20entered%20the%20date%20on%20worksheet2%20and%20the%20formula%20executes%20as%20required%2C%20the%20date%20remains%20on%20worksheet2.%20I%20need%20the%20worksheet2%20cell%20(sometimes%20multiple%20cells)%20to%20become%20blank%20again%20until%20another%20date%20is%20entered.%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERoy%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1419117%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1419228%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Data%20To%20Worksheet%201%20-%20Need%20Data%20Worksheet%202%20To%20Become%20Blank%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1419228%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F674997%22%20target%3D%22_blank%22%3E%40RoyJr%3C%2FA%3E%26nbsp%3BPerhaps%20a%20simple%20macro%20would%20be%20more%20efficient%20instead%20of%20formulas%20to%20avoid%20circular%20references.%20Pls%20see%20a%20sample%20in%20the%20attached%20workbook.%20Go%20to%20VBA%20Editor%20to%20check%20the%20macro%20codes%20and%20make%20the%20change%20to%20the%20cell%20reference%20and%20Sheet%20names%20as%20needed.%3C%2FP%3E%3CP%3EThe%20code%20is%20based%20on%20certain%20assumptions%3A%3C%2FP%3E%3CP%3E-%20Entered%20date%20is%20always%20inputted%20manually%20in%20cell%20A5%20of%20Sheet%201.%20Cell%20A5%20is%20formatted%20as%20Short%20Date%3CBR%20%2F%3E-%20Date%20in%20cell%20A5%20of%20Sheet%201%20would%20be%20transferred%20to%20the%20next%20row%20below%20the%20last%20used%20row%20in%20column%20A%20of%20Sheet%202%20(alternative%20code%20available%20if%20Date%20in%20cell%20A5%20of%20Sheet%201%20would%20be%20always%20transferred%20to%20a%20specific%20cell%20A2%20of%20Sheet%202%20for%20example)%3CBR%20%2F%3E-%20Cell%20A5%20of%20Sheet%201%20would%20be%20cleared%20once%20its%20date%20value%20has%20been%20transferred%20to%20Sheet%202%20(alternative%20code%20available%20if%20multiple%20cells%20of%20Sheet%201%20need%20to%20be%20cleared%20once%20date%20is%20transferred%20to%20Sheet%202)%3CBR%20%2F%3E-%20Column%20A%20of%20Sheet%202%20is%20formatted%20as%20Short%20Date%3C%2FP%3E%3CP%3E-%20The%20workbook%20must%20be%20saved%20either%20as%20.xlsm%20or%20.xlsb%20to%20contain%20the%20VBA%20macro%3C%2FP%3E%3CP%3EDisclaimer%3A%20I%20did%20not%20touch%20VBA%20for%20years%20so%20the%20codes%20would%20not%20be%20neat%20but%20it%20is%20functional%20I%20guess.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1438964%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Data%20To%20Worksheet%201%20-%20Need%20Data%20Worksheet%202%20To%20Become%20Blank%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1438964%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675276%22%20target%3D%22_blank%22%3E%40hynguyen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EStill%20working%20on%20this.%20Once%20complete%20and%20good-to-go%20will%20let%20you%20know.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1447212%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Data%20To%20Worksheet%201%20-%20Need%20Data%20Worksheet%202%20To%20Become%20Blank%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1447212%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675276%22%20target%3D%22_blank%22%3E%40hynguyen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20the%20workbook%20example.%20If%20possible%2C%20can%20you%20paste%20the%20code%20in%20the%20message%3F%20I%20am%20working%20from%20two%20computers%20and%20one%20does%20not%20have%20a%20full%20excel%20suite%2C%20so%20I%20cannot%20open%2Fcopy%20and%20paste.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERoy%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1447239%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Data%20To%20Worksheet%201%20-%20Need%20Data%20Worksheet%202%20To%20Become%20Blank%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1447239%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F674997%22%20target%3D%22_blank%22%3E%40RoyJr%3C%2FA%3E%26nbsp%3BHere%20are%20the%20codes%3A%3C%2FP%3E%3CP%3ESub%20Fill_Contents_Across_Sheets()%3CBR%20%2F%3E'%20Assumption%3A%20Entered%20date%20is%20always%20inputed%20manually%20in%20cell%20A5%20of%20Sheet%201.%20Cell%20A5%20is%20formatted%20as%20Short%20Date%3CBR%20%2F%3E'%20Assumption%3A%20Date%20in%20cell%20A5%20of%20Sheet%201%20would%20be%20transferred%20to%20the%20next%20row%20below%20the%20last%20used%20row%20in%20column%20A%20of%20Sheet%202%3CBR%20%2F%3E'%20Assumption%3A%20Cell%20A5%20of%20Sheet%201%20would%20be%20cleared%20once%20its%20date%20value%20has%20been%20transferred%20to%20Sheet%202%3CBR%20%2F%3E'%20Assumption%3A%20Column%20A%20of%20Sheet%202%20must%20be%20formatted%20as%20Short%20Date%3C%2FP%3E%3CP%3EDim%20LastRow%20As%20Long%3C%2FP%3E%3CP%3EWith%20ThisWorkbook%3CBR%20%2F%3E'%20Copy%20the%20date%20entered%20in%20cell%20A5%20of%20Sheet%201%3CBR%20%2F%3E.Sheets(%22Sheet1%22).Range(%22A5%22).Copy%3CBR%20%2F%3E'Find%20the%20last%20used%20row%20in%20column%20A%20of%20Sheet%202%3CBR%20%2F%3ELastRow%20%3D%20.Sheets(%22Sheet2%22).Cells(.Sheets(%22Sheet2%22).Rows.Count%2C%20%22A%22).End(xlUp).Row%3CBR%20%2F%3E'Paste%20special%20value%20and%20format%20the%20date%20from%20cell%20A5%20of%20Sheet%201%20to%20next%20row%20below%20the%20last%20used%20row%20in%20column%20A%20of%20Sheet%202%3CBR%20%2F%3E'.Sheets(%22Sheet2%22).Range(%22A%22%20%26amp%3B%20LastRow%20%2B%201).PasteSpecial%20Paste%3A%3DxlPasteValuesAndNumberFormats%2C%20Operation%3A%3D%20_%3CBR%20%2F%3ExlNone%2C%20SkipBlanks%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3E%3CBR%20%2F%3E'%20If%20the%20date%20is%20only%20transferred%20to%20one%20permanent%20cell%2C%20e.g.%20A2%20of%20Sheet%202%20then%20add%20'%20before%20previous%20black-font%20line%3CBR%20%2F%3E'%20and%20remove%20'%20before%20next%20green%20line%3CBR%20%2F%3E.Sheets(%22Sheet2%22).Range(%22A2%22).PasteSpecial%20Paste%3A%3DxlPasteValuesAndNumberFormats%2C%20Operation%3A%3D%20_%3CBR%20%2F%3ExlNone%2C%20SkipBlanks%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3E%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3E'%20Clear%20content%20in%20cell%20A5%20of%20Sheet%201%3CBR%20%2F%3E.Sheets(%22Sheet1%22).Range(%22A5%22).ClearContents%3CBR%20%2F%3E'%20If%20want%20to%20clear%20content%20in%20multiple%20cells%20in%20Sheet%201%2C%20e.g.%20A5%2C%20A10%2C%20D15%2C%20E20%2C%20add%20'%20before%20previous%20black-font%20line%3CBR%20%2F%3E'%20and%20remove%20'%20before%20next%20green%20line%3CBR%20%2F%3E'.Sheets(%22Sheet1%22).Range(%22A5%22%2C%20%22A10%22%2C%20%22D15%22%2C%20%22E20%22).ClearContents%3CBR%20%2F%3E%3CBR%20%2F%3E'%20Leave%20the%20cursor%20to%20cell%20A5%20of%20Sheet%201%3CBR%20%2F%3E.Sheets(%22Sheet1%22).Range(%22A5%22).Activate%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hello,

 

Using the below formula to copy the date from worksheet2 to worksheet1. It is working as it should (no date appears on worksheet1 until a date is entered on worksheet2. Once this occurs, the order on worksheet1 is closed and the order on worksheet2 disappears.)

 

=IF(Completed!$M$4="","",Completed!$M$4)

 

The problem I need help with is "once I have entered the date on worksheet2 and the formula executes as required, the date remains on worksheet2. I need the worksheet2 cell (sometimes multiple cells) to become blank again until another date is entered."

 

Thank you,

 

Roy

 

4 Replies
Highlighted

@RoyJr Perhaps a simple macro would be more efficient instead of formulas to avoid circular references. Pls see a sample in the attached workbook. Go to VBA Editor to check the macro codes and make the change to the cell reference and Sheet names as needed.

The code is based on certain assumptions:

- Entered date is always inputted manually in cell A5 of Sheet 1. Cell A5 is formatted as Short Date
- Date in cell A5 of Sheet 1 would be transferred to the next row below the last used row in column A of Sheet 2 (alternative code available if Date in cell A5 of Sheet 1 would be always transferred to a specific cell A2 of Sheet 2 for example)
- Cell A5 of Sheet 1 would be cleared once its date value has been transferred to Sheet 2 (alternative code available if multiple cells of Sheet 1 need to be cleared once date is transferred to Sheet 2)
- Column A of Sheet 2 is formatted as Short Date

- The workbook must be saved either as .xlsm or .xlsb to contain the VBA macro

Disclaimer: I did not touch VBA for years so the codes would not be neat but it is functional I guess.

Highlighted

@hynguyen 

 

Still working on this. Once complete and good-to-go will let you know.

 

Thanks.

Highlighted

@hynguyen 

 

Thanks for the workbook example. If possible, can you paste the code in the message? I am working from two computers and one does not have a full excel suite, so I cannot open/copy and paste.

 

Regards,

 

Roy

 

    

 

 

Highlighted

@RoyJr Here are the codes:

Sub Fill_Contents_Across_Sheets()
' Assumption: Entered date is always inputed manually in cell A5 of Sheet 1. Cell A5 is formatted as Short Date
' Assumption: Date in cell A5 of Sheet 1 would be transferred to the next row below the last used row in column A of Sheet 2
' Assumption: Cell A5 of Sheet 1 would be cleared once its date value has been transferred to Sheet 2
' Assumption: Column A of Sheet 2 must be formatted as Short Date

Dim LastRow As Long

With ThisWorkbook
' Copy the date entered in cell A5 of Sheet 1
.Sheets("Sheet1").Range("A5").Copy
'Find the last used row in column A of Sheet 2
LastRow = .Sheets("Sheet2").Cells(.Sheets("Sheet2").Rows.Count, "A").End(xlUp).Row
'Paste special value and format the date from cell A5 of Sheet 1 to next row below the last used row in column A of Sheet 2
'.Sheets("Sheet2").Range("A" & LastRow + 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False

' If the date is only transferred to one permanent cell, e.g. A2 of Sheet 2 then add ' before previous black-font line
' and remove ' before next green line
.Sheets("Sheet2").Range("A2").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False
' Clear content in cell A5 of Sheet 1
.Sheets("Sheet1").Range("A5").ClearContents
' If want to clear content in multiple cells in Sheet 1, e.g. A5, A10, D15, E20, add ' before previous black-font line
' and remove ' before next green line
'.Sheets("Sheet1").Range("A5", "A10", "D15", "E20").ClearContents

' Leave the cursor to cell A5 of Sheet 1
.Sheets("Sheet1").Range("A5").Activate
End With
End Sub