LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Paste Function Value


This code will fill the selected region with the formula "=sum($A2,B$3)
while maintaining correct relative references. Then it will copy an
paste special the resulting values.

This assumes that you have selected the range from the top left t
bottom right leaving your ActiveCell (the one that is not shaded) a
the top left.


Code
-------------------
Sub FillRange()
Dim fR As Integer, selRows As Integer, lR As Integer
Dim fC As Integer, selCol As Integer, lC As Integer

fR = ActiveCell.Row 'finds the first row of the selected area
selRows = Selection.Rows.Count 'finds the number of rows in the selected area
lR = fR + selRows - 1 'finds the last row of the selected area
fC = ActiveCell.Column 'finds the first column of the selected area
selCol = Selection.Columns.Count 'finds the number of columns in the selected area
lC = fC + selCol - 1 'finds the last column of the selected area
ActiveCell = "=sum($A2,B$3)"
ActiveCell.AutoFill Destination:=Range(Cells(fR, fC), Cells(fR, lC)), Type:=xlFillDefault
Range(Cells(fR, fC), Cells(fR, lC)).AutoFill Destination:=Selection, Type:=xlFillDefault
Selection.Copy
Selection.pastespecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End Su
-------------------


HT

--
bhofset
-----------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...fo&userid=1880
View this thread: http://www.excelforum.com/showthread.php?threadid=37983

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Paste function Mike O.[_2_] Excel Discussion (Misc queries) 2 October 21st 09 07:11 PM
Paste Special Function Steven D Excel Worksheet Functions 8 November 3rd 08 06:40 PM
copy and paste function mike3004 Excel Worksheet Functions 9 May 27th 08 01:28 PM
Paste all function Clairemont Excel Discussion (Misc queries) 0 November 24th 07 08:35 PM
Paste Link Function naiveprogrammer Excel Discussion (Misc queries) 2 August 8th 05 03:49 PM


All times are GMT +1. The time now is 11:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"