Vba Paste address based on the result of excel formula

guilhermepa

New Member
Joined
Jun 19, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I need to paste text from windows clipboard on an excel sheet using vba

Vba will paste the content from clipboard on a cell address given informed as value on a certain cell from excel

Example: cell H10 on excel contains the column value of F
Cell K20 on excel contains the row value of 40





Sub test ()

Dim column As string ' tried as integer too by converting excell column into a number but did not work

Dim row As integer

column = Cells(1,2).value ' supposing the column value is given on that specified addrress

row = Cells(5,6).value ' supposing the row value is given on that specified addrress

Worksheets("worksheet_name").cells(column,row).PasteSpecial ' it is going to paste a text from clipboard

End sub


It gives me error 1004
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Cells uses row,column format
Range uses column row format

So you might want to try
Worksheets("worksheet_name").cells(row, column).PasteSpecial ' it is going to paste a text from clipboard
 
Upvote 0
Thank you!! I also tried this and worked

Sub paste ( )

Dim linha As Integer
Dim coluna As String

linha = Range("H10").Value 'could be any column and row
coluna = Range("HI I ").Value ' could be any column and row

Range(coluna & linha).PasteSpecial

End sub



Cheers from Brazil
 
Upvote 0
Solution

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

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
Back
Top