Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paste Special +VBA

Status
Not open for further replies.

davetek

Programmer
Oct 30, 2002
42
IE
hi,

i recored a macro that multiplies a column by 1. this macro simply copies a cell containing the digit 1 and uses the multiply option in the paste special tool.
however i want to hard code the digit 1 to vba code so as to avoid the selection.copy
any ideas...

below is the code i am currently using:

Range("I1").Select
Selection.Copy
Range("F2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlMultiply, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False


cheers...
 
The only way you can simplify this is by using Range("I1").copy
rather then select and then copy
To use the pastespecial method, it must pick up a range value

Rgds
Geoff
Si hoc legere scis, nimis eruditionis habes
 
Why would you want to do this in the first place? Multiplying the values by 1 will return the same values. It just seems like redundant code. But, you wouldn't be able to "hard code" this proceedure using the .pastespecial method. You would need to write a For... Next Loop to cycle through each cell in the range that you want to multilpy by 1.
 
exactly - to be able to paste, you must first copy

Rgds
Geoff
Si hoc legere scis, nimis eruditionis habes
 
the problem is that i am importing a data set from a database which contains both text and numbers...the format function in excel will not allow me to format the numbers.
the only way i can format the numbers is by first multiplying them by 1. they are then recognised as a number and hence excel will allow formatting...
 
What if you used the Cdbl() or Cint() Functions to force the value to a double or long data type?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top