473,563 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel 2000 Date issue when transferring to new workbook

63 New Member
I have a problem in Excel 2000. I have written some VBA code that transfers data from the current excel workbook to a file called "Deal Input2.xls". Everything transfers ok apart from the date in cell ("G28"). This gets converted into an American date in Deal input 2.xls. So even though the date in the current workbook is entered as 02/05/2008 the info gets transferred to deal input2.xls as 05/02/2008. I've played around by trying to change the format of the cell in both files to text, different date formats etc - but it doesn't seem to make much difference. I've heard that a command called local:=true might be able to help me - but I have no idea where to add this! The current code is as follows: Any help would be greatly appreciated



Sub Import()

Dim stdocname As String
Dim DealNo As Range
Dim DealDate As Range
Dim ValDate As Range
Dim Cparty As Range
Dim Ext_Name As Range
Dim Cucy1 As Range
Dim Cucy2 As Range
Dim Value1 As Range
Dim Value2 As Range
Dim XRate As Range
Dim spot As Range
Dim Draw As Range
Dim ESett As Range
Dim Canx As Range
Dim SettCode As Range
' Dim SendTo As String
' Dim objOL As New Outlook.Applica tion
' Dim objMail As MailItem
' Dim MyMessage As Range


Application.Scr eenUpdating = False

Set DealNo = Worksheets("Int ernal FX Contract").Rang e("G32")
Set DealDate = Worksheets("Int ernal FX Contract").Rang e("G9")
Set ValDate = Worksheets("Int ernal FX Contract").Rang e("G28")
Set Cparty = Worksheets("Int ernal FX Contract").Rang e("G17")
Set Ext_Name = Worksheets("Int ernal FX Contract").Rang e("B17")
Set Cucy1 = Worksheets("Int ernal FX Contract").Rang e("E31")
Set Cucy2 = Worksheets("Int ernal FX Contract").Rang e("E35")
Set Value1 = Worksheets("Int ernal FX Contract").Rang e("F31")
Set Value2 = Worksheets("Int ernal FX Contract").Rang e("F35")
Set XRate = Worksheets("Int ernal FX Contract").Rang e("F33")
Set spot = Worksheets("Int ernal FX Contract").Rang e("B22")
Set Draw = Worksheets("Int ernal FX Contract").Rang e("B24")
Set ESett = Worksheets("Int ernal FX Contract").Rang e("B26")
Set Canx = Worksheets("Int ernal FX Contract").Rang e("B28")
Set SettCode = Worksheets("Int ernal FX Contract").Rang e("F42")

If spot.Value = "True" Then

stdocname = "Q:\Reuters Analytical Models\Quantum\ Input\Deal Input2.xls"
Workbooks.Open Filename:=stdoc name, UpdateLinks:=Fa lse

Workbooks("Deal Input2.xls").Ac tivate
Sheets("Data"). Activate
If Range("B2") = "" Then
Range("A2").Val ue = "Dummy"
Else
End If
Rows("2:2").Sel ect
Selection.Inser t Shift:=xlDown
Range("A2").Val ue = DealNo.Value
Range("B2").Val ue = Cparty.Value
Range("C2").Val ue = Ext_Name.Value
Range("D2").Val ue = DealDate.Value
Range("E2").Val ue = ValDate.Value
Range("F2").Val ue = "Foreign Exchange Spot"
Range("H2").Val ue = Cucy1.Value
Range("I2").Val ue = Value1.Value
Range("J2").Val ue = Cucy2.Value
Range("K2").Val ue = Value2.Value
Range("L2").Val ue = XRate.Value
Range("O2").Val ue = SettCode.Value

If Range("A3").Val ue = "Dummy" Then
Range("A3").Val ue = ""
Else
End If

ActiveWorkbook. Close SaveChanges:=Tr ue

Else
End If
ActiveWindow.Se lectedSheets.Pr intout Copies:=1, Collate:=True

' Send confirmation e-mail

' SendTo = Range("F11").Va lue
' subj = "Successful ly processed - Foreign Exchange Contract"
' Set objOL = New Outlook.Applica tion
' Set objMail = objOL.CreateIte m(olMailItem)
' Set MyMessage = Range("A60")

' With objMail
' .To = SendTo
' .CC = sendcc
' .Subject = subj
' .Body = MyMessage.Value
' .Display
' End With

' objMail.Send
' Set objMail = Nothing
' Set objOL = Nothing
' Set MyMessage = Nothing


Application.Scr eenUpdating = True

End Sub
May 2 '08 #1
2 1695
kadghar
1,295 Recognized Expert Top Contributor
I have a problem in Excel 2000. I have written some VBA code that transfers data from the current excel workbook to a file called "Deal Input2.xls". Everything transfers ok apart from the date in cell ("G28"). This gets converted into an American date in Deal input 2.xls. So even though the date in the current workbook is entered as 02/05/2008 the info gets transferred to deal input2.xls as 05/02/2008. I've played around by trying to change the format of the cell in both files to text, different date formats etc - but it doesn't seem to make much difference. I've heard that a command called local:=true might be able to help me - but I have no idea where to add this! The current code is as follows: Any help would be greatly appreciated
Why dont you use a Date variable instead of a Range one, this might help a little bit, i.e:

instead of

Expand|Select|Wrap|Line Numbers
  1. Dim Canx As Range
define it as

Expand|Select|Wrap|Line Numbers
  1. Dim Canx As Date
This way, the date will be stored as a numeric value, and you'll forget about its format.

And then, when it's already in the new workbook, just change the cell's format:

Expand|Select|Wrap|Line Numbers
  1. Range("G28").NumberFormat = "m/d;@"
And always try to manage dates with numeric values, only formating them when showing them.

HTH.
May 2 '08 #2
grego9
63 New Member
Worked a treat - I had a few other issues with the set command - but I just removed Set and the .value bits against the relevant date and it worked fine.

Thanks for your help
May 7 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
25248
by: Geert-Pieter Hof | last post by:
Hello, My VB 6.0 application read and writes data from and to a MS Excel workbook, using the Microsoft.Jet.OLEDB.4.0 provider. Now I want to protect the Excel workbook with a password, but I figured out that it is not possible to open the workbook for data access with ADO (http://support.microsoft.com/?KBID=211378). Is there another...
6
18826
by: Paul | last post by:
I was wondering if anyone has had an issue where using vba code to read an excel file and import the data into an access table some records are not imported from the excel file. It seems looking at the data in the excel file that if the first character in the excel file cell is numeric it will read and write only numeric values only. If I...
8
6544
by: Nick M | last post by:
Hello All, Excellent info here Thanks! I am very new to using access in general and I am on a learning curve. I'm trying to import an excel workbook (with worksheets) into an access db via a macro. (I'll get to using VB later on). What I would like to do is import a single workbook w/three seperate worksheets into three seperate access...
6
12475
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C# application. It seems simple enough, but the problem I'm encountering is as follows: In order for the user to select the cell from Excel, they must first...
1
2143
by: kumar yogesh via .NET 247 | last post by:
Hello, I want to develop an application to transfer data from sqlserver to excel such that , when we create a workbook in excel ,then we are able to transfer data from SQL Server to excel in away that the first three columns of the table (In SQL Server)move to the First Worksheet of the workbook,the next set ofthree columns moves to the Second...
8
788
by: Sam | last post by:
Hi All, I posted this message few days ago. No one has answered so far. I just would like to know if it is possible to do or not. Even if you can not tell me how to do this, maybe you know which library I need to use in order to access excel information from a VB.NET code. For example, I would be interested by knowing how to access a simple...
0
1182
by: Larry Jones | last post by:
I am pulling Excel single cell information from a workbook to a textbox in a VB.net form. Most of the information is transferring without a problem, but some cells with function calculations are transferring erroneous figures. Is there a method to either change syntax in VB.net or change formatting in Excel to transfer the correct number? I...
7
2418
by: Alain \Mbuna\ | last post by:
Hi everybody. In my program I have some data that is calculated after some input from the user. I have written some code that opens an Excel workbook, with 5 worksheets and the calculated data (no database!)with some titles and info, is entered in the worksheet in a printable format. This is some of the code... Public exlAppl As...
2
2302
by: Jim S | last post by:
To my surprise and chagrin, newer versions of Access have disabled the functionality that lets users change the data in linked tables that point to a range in an Excel workbook. This is "because of legal issues..." according to Office Support. I have other issues, specifically a couple of applications that do things such as calculate price...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.