Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / November 2007

Tip: Looking for answers? Try searching our database.

highlight range, apply calculation to data in cells and paste special to same range

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
S Himmelrich - 06 Nov 2007 21:48 GMT
I know how to select a range of cells and copy:

   Range("O2").Select
   Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
   Selection.Copy

but now
1.  applying the calculation, which should be value of cell * 1000
2.  special past values only to same selected sells

?
OssieMac - 06 Nov 2007 22:02 GMT
You enter 1000 in a separate blank cell and copy it then highlight the range
to be multiplied and past special-> multiply. that will multiply all the
cells by 1000 in the pasted range.

Regards,

OssieMac

> I know how to select a range of cells and copy:
>
[quoted text clipped - 7 lines]
>
> ?
Earl Kiosterud - 06 Nov 2007 23:48 GMT
Himmelrich,

If you're going to do this with a macro, you can do it like this.  You don't need the
copy/paste, or the selection part.

  Dim Thing As Range
  For Each Thing In Range("O2", Range("O2").SpecialCells(xlLastCell))
    Thing.Value = Thing.Value * 1000
    Next Thing

I used your SpecialCells(xlLastCell) construct, but note that that will include the cells
from O2 to the lower-right most cell in the sheet with anything in it (or ever had anything
in it). Maybe you meant only to go downwards in column O until there's an empty cell.  In
that case, change the line to:

 For Each Thing In Range(("O2"), Range("O2").End(xlDown))

Or if there might be empty cells in the column:

 For Each Thing In Range("O2", Cells(Cells.Rows.Count, Range("O2").Column).End(xlUp))

These will fail if there is text in a cell being multiplied.
Signature

Regards from Virginia Beach,

Earl Kiosterud
www.smokeylake.com

   Note: Top-posting has been the norm here.
   Some folks prefer bottom-posting.
   But if you bottom-post to a reply that's
   already top-posted, the thread gets messy.
   When in Rome...
-----------------------------------------------------------------------

>I know how to select a range of cells and copy:
>
[quoted text clipped - 7 lines]
>
> ?

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.