Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Adding data to a closed sheet

Will it be possible to copy data (6 consecutive cells) from my current sheet
to the end of another sheet that is not currently open.
Many thanks
Dan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Adding data to a closed sheet

1. open the closed workbook
2. perform the copy/paste
3. re-close the previously closed workbook
--
Gary''s Student - gsnu200790


"Dan" wrote:

Will it be possible to copy data (6 consecutive cells) from my current sheet
to the end of another sheet that is not currently open.
Many thanks
Dan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Adding data to a closed sheet

Hi Dan, try
http://www.rondebruin.nl/copy1.htm

See the last example
"What if the Database sheet is in another workbook"




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Dan" wrote in message ...
Will it be possible to copy data (6 consecutive cells) from my current sheet
to the end of another sheet that is not currently open.
Many thanks
Dan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Adding data to a closed sheet

Hi Dan,
Gary's resopnse is correct but to give a little more meat to bones of what
he is saying an approach along the lines of following could be used. The
FileLocked function checks to see if the file is already open read / write
mode. This is not something I have written (sorry to author for not giving
credit) but I make extensive use of it in various applications. You should
get the general idea of how to apply what Gary was saying to.

Hope helpful

Sub AddToFile()
Dim DestWB As Workbook
Dim DBFile As String
Dim mytitle As String

mytitle = "Add Data To File"

DBFile = "C:\WhichDirectory\WhichFile.xls" '<< change as required

'Check if Read / Write File Already Open
If FileLocked(DBFile) Then
msg = MsgBox("Read / Write File Already Open.", 16, mytitle)

Else
Set DestWB = Workbooks.Open(DBFile, Password:="mypassword")

'do your stuff here

DestWB.Close True

End If
End Sub

Function FileLocked(strFileName As String) As Boolean

On Error Resume Next

' If the file is already opened by another process,
' and the specified type of access is not allowed,
' the Open operation fails and an error occurs.
Open strFileName For Binary Access Read Lock Read As #1
Close #1

' If an error occurs, the document is currently open.
If Err.Number < 0 Then
FileLocked = True
Err.Clear
End If
On Error GoTo 0
End Function





--
jb


"Dan" wrote:

Will it be possible to copy data (6 consecutive cells) from my current sheet
to the end of another sheet that is not currently open.
Many thanks
Dan

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
adding new data to another sheet from the main sheet ycwkpp898 Excel Discussion (Misc queries) 1 January 6th 09 04:16 PM
Searching and adding in a closed file Dr. Schwartz[_2_] Excel Programming 3 January 29th 08 02:58 PM
Consolidation of data from cell in active sheet of closed workbook Neil X Peel Excel Worksheet Functions 3 March 8th 07 02:35 PM
adding data from one sheet to another sheet as a dropdown list bo. gatorguy Excel Discussion (Misc queries) 1 February 18th 05 10:51 PM
Adding all the data to one sheet Mac[_6_] Excel Programming 3 January 8th 04 01:54 PM


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

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"