Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default #VALUE error in UDF again

Aivars,
I'm not certain of this, but try changing With Worksheets(1).Range("a1")
to With Worksheets("Sheet1").Range("a1")

HTH
Henry

"Aivars" wrote in message
om...
Hello,
I have a worksheet where I use an UDF with seven arguments. The values
for these arguments come from worksheet cells.

There is a button (from Forms toolbar) with the following macro
attached to it for copying over the network:

Sub CopyToNewBook()
Dim oldBook As Excel.Workbook
Dim oldSheet As Excel.Worksheet
Dim rgRange As Range
Dim newSheet As Worksheet
Dim newBook As Workbook

Application.ScreenUpdating = False
Set oldBook = ThisWorkbook
Set oldSheet = oldBook.Worksheets("Cash_Flow")

'copy sheet to new workbook
Set newBook = Workbooks.Add
Set newSheet = newBook.Worksheets("Sheet1")

oldSheet.Cells.Copy
With newBook
With Worksheets(1).Range("a1")
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
Range("B3").Select
End With
Application.DisplayAlerts = False
.SaveAs "\\Clk_tanker_server\TANKER\Users\Akmens\No Aivara\New
Book.xls"
.Close SaveChanges:=True ''' after this statement there are
#VALUE error
End With
Application.CutCopyMode = False

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

Pressing F9 restores everything back OK.
Could it be that UDF uses the arguments from cells?

Thanks in advance

Aivars



Reply
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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
Error: "Excel encountered an error and had to remove some formatti Carl Excel Discussion (Misc queries) 0 September 18th 06 06:39 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
I have Error 1919 Error Configuring ODBC dataSource Database Texanna1 Excel Discussion (Misc queries) 1 September 12th 06 06:35 AM


All times are GMT +1. The time now is 11:05 PM.

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

About Us

"It's about Microsoft Excel"