0

Noob to VBA and macros, so hoping someone help me solve this problem, please.

I am starting by copying the data from an email and then the macro pastes that data from the clipboard on the excel sheet. The first couple of statements in the macro start as:

Section 1
Sub Macro1 ()
Sheets.Add.Name = "Sheet2"
ActiveSheet.Paste Destination:=Range("a2")
.Do step a
.Do step b
.Do Step c
and so on..

So the above steps copy the data from the clipboard and place them in Cell A2 in Sheet 2 and then there're few more steps added to manipulate this data (Step a, b, c etc.). Then macro needs to move to Sheet 1 and manipulate already existing data there as below:

Section 2
Sheets("Sheet1").Select
Cells.Select
Selection.UnMerge
.Do Step d
.Do Step e
.Do Step f
.and so on....

End Sub

The problem I am having is that there're times when I do not need to copy data from the email, so the clipboard is empty. In that case, I need the macro to skip steps in the first section and perform the steps under section 2 only. What kind of VBA statement do I need to accomplish that, please?

Thank you so much for your help!!

Navv
  • 1
  • 1) Do a `If..Then` statement and skip the steps in first section if it fulfills the condition for "no need to copy data from the email"? 2) You will benefit from reading [this](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba?noredirect=1&lq=1) on how to avoiding using Select in your code. – Raymond Wu Aug 02 '21 at 04:59

0 Answers0