Pasting an Integer Variable Value into a Worksheet

SBF12345

Well-known Member
Joined
Jul 26, 2014
Messages
614
Greetings,

I would like to paste an integer variable value into a cell on a worksheet. Here is a bit of the code I am working with.

C is the variable
Code:
C = PA.ws.Range(Cells(D, "A"), Cells(G, "A")).Rows.Count

The code below gives a compile error at "C.Copy"
Code:
C.Copy                TA.ws.Range("A1").End(xlDown).Offset(0, 5).Select
                Selection.Paste PasteSpecial:=xlValues

I would like to copy the number of rows into a cell on a worksheet. Other methods?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Greetings,

I would like to paste an integer variable value into a cell on a worksheet. Here is a bit of the code I am working with.

C is the variable
Code:
C = PA.ws.Range(Cells(D, "A"), Cells(G, "A")).Rows.Count

The code below gives a compile error at "C.Copy"
Code:
C.Copy                TA.ws.Range("A1").End(xlDown).Offset(0, 5).Select
                Selection.Paste PasteSpecial:=xlValues

I would like to copy the number of rows into a cell on a worksheet. Other methods?
Your question is not entirely clear to me. Just a guess... assume D=5 and G=9 as an example, are you trying to copy the data in the cells A5:A9 into one single cell or are you trying to put the count of the number of cells in the range A5:A9 (5 total cells) into that one single cell? Or are you trying to do something else instead?
 
Upvote 0
One doesn't copy variables. But one can put a variable into a cell (without Paste, since Paste is for Copied things)


Code:
TA.ws.Range("A1").End(xlDown).Offset(0, 5).Value = C
 
Upvote 0
I am shooting for the count value of the range using the two other variables.

Thanks, I can assign the value with the .value = C
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

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