Creating Range in VBA Code and using Pastespecial

B

blisspikle

Is the anyway use similiar code as below, but create a Range in VBA
without using an actual range in excel... I would just like to use
the pastespecial function and divide my selection by a number without
having to write the number in a cell, then copy it, and then use
pastespecial, then have to delete the cell.

<Code>
Selection.Copy
Columns("M:M").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlDivide,
SkipBlanks _
:=False, Transpose:=False
</Code>
 
P

Per Jessen

Hi

Maybe this will help you:

Dim TargetCell As String
TargetCell = "A1" ' change to suit
Range(TargetCell) = 10 ' change to suit or use variable
Range(TargetCell).Copy
Columns("M:M").PasteSpecial Paste:=xlPasteAll, Operation:=xlDivide, _
SkipBlanks:=False, Transpose:=False
Range(TargetCell).Clear

Regards,
Per
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top