PDA

View Full Version : VBA Clipboard Statement



naveen_jaina
08-01-2021, 07:10 PM
Hello,

I am new to VBA and macros, so hoping some one 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. First couple of statements in the macro start as:
------------------------------------
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 places 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:
-----------------------
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 I need to accomplish that please?

Thank you so much for your help!!