LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Creating an Excel Database in Separate Workbook

Hi Brian

The range is not valid in your code and I don't know if the sheet name is correct with the space between the t and 3

Sheets("Sheet 3").Range("A:7")

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Brian C" wrote in message ...
Hi Ron,

I realize it's about 8:00pm. I tried the code below, and got a Syntax error
on the Set rng= ... command.

With destWB.Sheets("Sheet 3").Range("A:7")
Set rng = .Find(What:=sourceRange.Cells(1).Value,_
After:=.Cells(.Cells.Count), _


Thanks,

Brian

"Ron de Bruin" wrote:

Hi Brian

Try this one that copy A1:H1 to the Database workbook

Sub copy_to_another_workbook_test()
Dim sourceRange As Range
Dim destrange As Range
Dim destWB As Workbook
Dim Lr As Long
Dim rng As Range
Dim answer

Application.ScreenUpdating = False
If bIsBookOpen("test.xls") Then
Set destWB = Workbooks("test.xls")
Else
Set destWB = Workbooks.Open("c:\test.xls")
End If

Lr = LastRow(destWB.Worksheets("Sheet1")) + 1
Set sourceRange = ThisWorkbook.Worksheets("Sheet1").Range("A1:H1")
Set destrange = destWB.Worksheets("Sheet1").Range("A" & Lr)


With destWB.Sheets("Sheet1").Range("A:A")
Set rng = .Find(What:=sourceRange.Cells(1).Value, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)


If Not rng Is Nothing Then
answer = MsgBox("Do you want to overwrite the existing data ", vbYesNo, "something")
If answer = vbYes Then
sourceRange.Copy
rng.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
destWB.Close True
Else
sourceRange.Copy
destrange.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
destWB.Close True
End If

Else
sourceRange.Copy
destrange.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
destWB.Close True
End If
End With

Application.ScreenUpdating = True

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Brian C" wrote in message ...


Ron,

Enjoy your meal. Thanks alot for all your help.

Brian






 
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
Creating a Database in Excel Kevin New Users to Excel 9 September 11th 06 02:11 PM
Help needed on creating Excel database JM Excel Discussion (Misc queries) 1 March 20th 06 07:26 PM
creating database from excel spreadsheet trjdba Excel Programming 1 October 4th 04 08:52 PM
Creating a database in Excel Rachel[_5_] Excel Programming 1 September 14th 04 09:01 PM
Creating an Excel Database! eijaz Excel Programming 2 November 15th 03 02:40 AM


All times are GMT +1. The time now is 07:11 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"