Count the rows in the clipboard

2077delta

Board Regular
Joined
Feb 17, 2002
Messages
242
I am copying information from a data extraction application called Monarch and then pasting it into Excel. The data to be pasted has to be inserted in between some existing data in the worksheet. Is there a way to count the number of rows in the clipboard so I can insert this number of rows into my worksheet then paste the data from the clipboard?
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Gary McMaster

Well-known Member
Joined
Feb 8, 2009
Messages
1,977
The following might work if you don't have linefeeds embedded in individual cells.

However, it might be easier to just paste the data into a "temp" worksheet at cell "A1" then count the rows in the temp sheet.

Hope it helps.

Gary

Code:
Public Sub Test()

'Need reference to Microsoft Forms 2.0 Object Library
Dim oClip As New MSForms.DataObject
Dim vSplit As Variant

oClip.GetFromClipboard
vSplit = oClip.GetText

vSplit = Split(vSplit, vbCrLf)

MsgBox UBound(vSplit) & " Rows"

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,215
Messages
5,594,883
Members
413,947
Latest member
gizmolucy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top