View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Excel macro script to copy only formulas and not values from one sheet to another

Use an inputbox for each.

Sub test()
Application.ScreenUpdating = False
Dim srcSh As Worksheet, r As Range, c As Range
Dim destSh as Worksheet, src as string, dest as string
src = InputBox("Enter Source Sheet Name")
dest = Inputbox("Enter Destination Sheet Name")
if src = "" or dest = "" then
msgbox "missing sheet name"
exit sub
end if
On error resume Next
set srcSh = Worksheets(src)
set destSh = Worksheets(dest)
On Error goto 0
if srcSh is nothing or destSh is nothing then
msgbox "Non existent sheet"
exit sub
End if
With srcSh
Set r = .Cells.SpecialCells(xlCellTypeFormulas, 23)
End With
For Each c In r
c.Copy destSh.Range(c.Address)
Next c
Application.ScreenUpdating = True
End Sub

Untested, so there may be typos.

--
Regards,
Tom Ogilvy



--
Regards,
Tom Ogilvy

"Katherina Holzhauser" wrote in message
...
Great - this one worked. One enhancement request: How do I prompt the
user to fill in the name of the sheet they want to copy from and the
name of the sheet they want to copy to?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!