greenmonster15
Board Regular
- Joined
- Aug 28, 2012
- Messages
- 70
Goal:
I have data that was copied to my clipboard from the webpage source in a Chrome browser. I would like to get that data over to my excel worksheet and insert it starting at "A1".
Issue:
All of the pasted data is ending up in ONLY cell "A1" when using VBA (probably because it is a better listener than I am a programmer)
When I just click in cell "A1" and CTRL-V, the data gets spread across a lot of cells, which is what I am after.
I have data that was copied to my clipboard from the webpage source in a Chrome browser. I would like to get that data over to my excel worksheet and insert it starting at "A1".
Issue:
All of the pasted data is ending up in ONLY cell "A1" when using VBA (probably because it is a better listener than I am a programmer)
When I just click in cell "A1" and CTRL-V, the data gets spread across a lot of cells, which is what I am after.
Code:
'------------------------------------------
'Start The Process
'------------------------------------------
[B]' Assigning clipboard data to string variable strClip
Dim MyData As DataObject
Dim strClip As String
Set MyData = New DataObject
MyData.GetFromClipboard
strClip = MyData.GetText[/B]
'---------------------------------------------------------
Set TempSheet = Worksheets("Temp")
Set MainSheet = Worksheets("Sheet1")
Application.DisplayAlerts = False
TempSheet.Delete
Set NewSheet = Application.Worksheets.Add(After:=Worksheets(Worksheets.Count)) ' "Sheet1"))
NewSheet.Name = "Temp"
Application.DisplayAlerts = True
Set TempSheet = Nothing
Set TempSheet = Worksheets("Temp")
' Pasting website source data from clipboard to Temp sheet to be evaluated
Dim FirstCell As Range ' First cell to contain desired data to extract
Dim LastCell As Range ' Last cell to contain desired data to extract
Dim TargetRng As Range
Dim lngLastRow As Long
Dim lngLastCell As Long
[B] TempSheet.Activate
TempSheet.Cells(1, 1).Activate
ActiveCell.Value = strClip[/B]