0

Update macro writes data from "Input" worksheet to "Orders" worksheet. I want to initialize data on Input sheet but it also clears data written to Orders sheet. Any help will be appreciated. Update Macro:

Sheets("Orders").Select
Range("B2").Select
ActiveCell.FormulaR1C1 = "=Input!R17C7"
Range("C2").Select
ActiveCell.FormulaR1C1 = "=Input!R17C9" 

Initialize Macro: clears data in both sheets

Sheets("Input").Select
Range("G17").Select
Selection.ClearContents
Range("I17").Select
Selection.ClearContents
Jim C
  • 1

2 Answers2

1

You should avoid the .Select & .Selection method when possible. Please see this link for more information on that.

Notice how you can skip those lines and jump right to the conclusion:

Thisworkbook.Sheets("Orders").Range("B2").FormulaR1C1 = "Input!R17C7"
Thisworkbook.SHeets("Orders").Range("C2").FormulaR1C1 = "Input!R17C9"

&

Thisworkbook.Sheets("Input").Range("G17:I17").ClearContents
urdearboy
  • 14,439
  • 5
  • 28
  • 58
0

Write only these two lines

Sheets("Input").Range("G17").ClearContents
Sheets("Input").Range("I17").ClearContents

to clear the contents in G17 and I17 of "Input".

Vityata
  • 42,633
  • 8
  • 55
  • 100