I have a excel macro like this:
1. Range("C2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Replace What:=".", Replacement:="/", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.NumberFormat = "[$-409]d-mmm-yy;@"
Selection.TextToColumns Destination:=Range("C2"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
2. Columns("M:M").Select
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Columns("L:L").Select
Selection.TextToColumns Destination:=Range("L1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=":", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Can you please suggest me the replacement function or the code for above in Access.
1 3581
Hi
I have a excel macro like this:
1. Range("C2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Replace What:=".", Replacement:="/", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.NumberFormat = "[$-409]d-mmm-yy;@"
Selection.TextToColumns Destination:=Range("C2"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
2. Columns("M:M").Select
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Columns("L:L").Select
Selection.TextToColumns Destination:=Range("L1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=":", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Can you please suggest me the replacement function or the code for above in Access.
First you need to use Automation to open an instance of excel and then open your workbook in that instance, somethink like this - On Error Resume Next
-
Dim oExcel As Object
-
Set oExcel = GetObject(, "Excel.Application")
-
-
If Err.Number <> 0 Then
-
Err.Clear
-
Set oExcel = CreateObject("Excel.application")
-
End If
-
-
If Err.Number <> 0 Then
-
MsgBox "Could not open Excel!", vbCritical
-
Exit Sub
-
End If
-
-
-
oExcel.Workbooks.Open ("FilePath&NameToOpen")
-
-
-
If Err.Number <> 0 Then
-
MsgBox "Could not open workbook '" & FileToOpen & "' !", vbCritical
-
If oExcel.Workbooks.Count = 0 Then oExcel.Close
-
Exit Sub
-
End If
-
-
On Error GoTo 0
Then all your excel code need Refering to the excel object and/or workbook object.
Also, if you want to see excel at the end it has to be visible (oExcel.Visible=True) !?
BTW the obove uses late binding to get any open excel application if there is one, if not, it opens a new one.
I think that should keep you busy for a start.
Good luck
MTB
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Steven Stewart |
last post by:
I have a user who has been using Excel for a while to keep statistics
and print reports. She finds using it cumbersome because of long
formulas and a lot of copying and pasting.
I have designed...
|
by: Mads Petersen |
last post by:
I'm stuck in this code. Hope you can and will help me. I launch it
from excel.
I have made the following code work, but not as i whant. I need the
ranges to be working with something like xlDown....
|
by: Arno R |
last post by:
Hi all,
I will have to handle a lot of really 'nice' data in a LOT of Excel sheets. It is all about music files (Billboard top 100)
I am afraid there really is a sheet for every year ... (Don't...
|
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...
|
by: Conrad F |
last post by:
Hello All,
I know how to import a specific named excel sheet into a datagrid
using ADO.NET by setting up a JET connection and then SELECTing data
from the sheet. However, for a real world...
|
by: Robert Bravery |
last post by:
HI all,
I'm new to C#.
I want to open an excel document and work with it in C#.
I currently have Excel2000, I think it is version9.0. But Clients might have
office XP, XP2003 on
Could someone...
|
by: rlntemp-gng |
last post by:
RE: Access 2003/Excel 2003
Problem:
After I close the Access application completely, I go out to the Task
Manager and there is an Excel.exe object still sitting out there.
My Access...
|
by: Sajit |
last post by:
I am trying to use an Excel file as a
template for an Access report. I Linked
the Excel file through an unbound frame as
an OLE object with the properties set as
follows:
Source Doc...
|
by: DrewYK |
last post by:
I have the project that may never end in front of me.
I am creating a routine that will take SpreadSheets from Excel and
bring them into Access.
I am not using any "DoCmd"s because the goal...
|
by: kpresidente |
last post by:
Hello all,
I'm trying to transfer the value of a control on an Access form to an Excel worksheet using VBA. The Access form is a single form with all the controls disabled, so that data is "read...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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,...
|
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...
| |