Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Get Data From Excel And Match With SQL Data


Hi all,

My boss asked me to write a program which will open a SQL database, run a query, pull some data (4 columns), concatenate this data with some text, and save the result into a tab delimited text file. Somehow (with the help of postings in this forum and some luck) I got the program working. Now we found out that 2 columns contain wrong info, so the fix is to get data from an Excel file. The idea is to read the 2 columns in the Excel file, match them with the other 2 good columns from SQL database, and then output them to the tab delimited text file (of course after concatenation). To make it even worse, the Excel is password protected for open and modify. First of all, is this doable?

I searched this forum and this is what I’ve been trying to use, unsuccessfully I might add:


Code:
Private Sub Form_Load()
Dim xlApp As Excel.Application
Dim xw As Excel.Workbooks ' for references to workbooks!

' First see if Excel is already running
On Error Resume Next
Set xlApp = GetObject("C:Test.xls")
On Error GoTo 0

Set xw = xlApp.Workbooks

xw.Open " C:Test.xls "
labelStatus.Caption = "Loaded successfully!"

' Get SQL data and do manipulations here. ...

'xw.Close
End Sub
When I run this I get a “Run-time error 91 – Object variable With block variable not set” on this line:


Code:
Set xw = xlApp.Workbooks
When I step thru the program I can also see that xlApp is set to Nothing…

Can anyone help please?

Thanks a lot,
mike




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Match The Data
Hello guys..

I have problem here. How to match the data from ComboBox to Database. Detail information as below:-

1. ComboBox - contain letter from A to Z
2. SQL database - contain a few letter (ex: A, B, F and G)

I want to hide letter A, B, F and G in ComboBox. Because I want to make sure there are no same letter in database when I save it later on.

So, first how to match letter in database to letter in ComboBox and
second hide letter in ComboBox when it match.

Plz somebody help. I'm urgent on it.

TQ

Match Data
i want to check the barcode that we scan is 10 digit or not. Could u help me in that? And there's 4 kinds of different barcodes.
First, we will choose the BeamSize(in attached). Then we will check the BeamSize that we select and the BarCode(in attached) that we scan is matched.
 
For example,
If we choose 24" Platen Beam , then the BarCode we scan should be start with Q5669-*****
44" Platen Beam, BarCode should be starting with Q6659-*****
24" Taj Mahal, BarCode should be Q6683-*****
44" Taj Mahal, BarCode Q6687-*****

Is it about Like operator?



Edited by - mont on 2/5/2007 5:22:08 PM

Match Data On Report
Hi,
I want to set my data on the report.I need to set a data on bottom of the report,But when I put the data in page footer it prints in middle of the page.
How can I remove this problem ?

Regards,
Saeed

Urgent Data Report Error "Report Sections Do Not Match Data Source"
hi this is my code when i try to run the report, the error message will come out saying that "Report section do not match data source" thanks

datefrom1 = Format(DTPicker3.Value, "mm/dd/yyyy")
dateto1 = Format(DTPicker4.Value, "mm/dd/yyyy")
z = 0
medicationreport.Sections("Section4").Controls.Item("lblfrom").Caption = DTPicker3.Value
medicationreport.Sections("Section4").Controls.Item("lblto").Caption = DTPicker4.Value
          strConn = ("Driver={SQL Server};Server={.};database=ccmsEquine;Uid=;Pwd=;")
          conn.Open strConn
          Set rs1 = conn.Execute("SELECT count(*) FROM Drug D, Vdrug VD, Visit V WHERE V.visit_id = VD.visit_id AND D.drugid = VD.drug_id AND V.Time_in >= '" & datefrom1 & "' AND V.Time_in <= ('" & dateto1 & "')")
          numf = rs1(0)
          rs.Open "SELECT D.Druggroup,D.brand,SUM(VD.Qty)as qty,SUM(VD.UnitCost)as unitcost FROM Drug D, Vdrug VD, Visit V WHERE V.visit_id = VD.visit_id AND D.drugid = VD.drug_id AND V.Time_in >= '" & datefrom1 & "' AND V.Time_in <= ('" & dateto1 & "') GROUP BY D.DrugGroup,D.brand ORDER BY D.druggroup,D.brand", conn, adOpenStatic, adLockReadOnly
          
          If numf > 1 Then
          With medicationreport
              Set .DataSource = Nothing
              .DataMember = ""
              Set medicationreport.DataSource = rs
              With .Sections("Section6").Controls
                For intCtrl = 1 To .Count
                      'Place one unbound text at the details
                       If TypeOf .Item(intCtrl) Is RptTextBox Then
                            .Item(intCtrl).DataMember = ""
                            .Item(intCtrl).DataField = rs(z).Name
                            z = z + 1
                       End If
                  Next intCtrl
                End With
              With .Sections("Section1").Controls
                   For i = 1 To .Count
                      'Place one unbound text at the details
                       If TypeOf .Item(i) Is RptTextBox Then
                            .Item(i).DataMember = ""
                            .Item(i).DataField = rs(z).Name
                            z = z + 1
                       End If
                  Next i
               End With
               .Show
          End With

Data Doesn't Match In Both Forms??
Hi experts, I have 2 forms in my project. 1 is the Add and Remove form and the other one is the Reservation form. I have been trying to figure out why the data in my Add and Remove form doesn't match the Reservation form when I write the code to transfer over.

These are some of the codes which the error lies in.

This is what I wrote for the Add and Remove form............

Code:
option Explicit
'user defined datatype
Private Type movieRecord
id As String * 1
title As String * 20
theatre As String * 1
price As Currency

time1 As String * 4
time2 As String * 4
time3 As String * 4
time4 As String * 4
time5 As String * 4
time6 As String * 4
time7 As String * 4


End Type

Const MOVIEFILE As String = "movie.txt"

Dim gRecNo As Integer ' current record no.
Dim gTotRec As Integer ' total no. of records in file
Dim gmovie As movieRecord

Private Sub cmdAdd_Click()

'This is to make sure that only numeric characters in input

Dim strTemp As String
Dim intIndex As Integer

strTemp = txtadd.Text

If strTemp = "" Then 'ok with no test
MsgBox "Textbox is empty", , ""
Else
'loop through all chars in the string
For intIndex = 1 To Len(strTemp) Step 1
Select Case Asc(Mid$(strTemp, intIndex, 1))
Case 48 To 57 'numeric
Case Else 'non-numeric
MsgBox "Invalid Input! Enter numbers only", , ""
intIndex = Len(strTemp) 'end loop

End Select
Next intIndex

End If

End Sub

Private Sub initAddMovie()
txtStatus.Text = "Add Movie"
'clear input fields
txtid.Text = ""
txttitle.Text = ""
txttheatre.Text = ""
metprice.Text = ""

txttime1.Text = ""
txttime2.Text = ""
txttime3.Text = ""
txttime4.Text = ""
txttime5.Text = ""
txttime6.Text = ""
txttime7.Text = ""

'set controls

txttime1.Enabled = True
txttime2.Enabled = True
txttime3.Enabled = True
txttime4.Enabled = True
txttime5.Enabled = True
txttime6.Enabled = True
txttime7.Enabled = True

txtid.Enabled = True
txttitle.Enabled = True
txttheatre.Enabled = True
metprice.Enabled = True
mnuEditEdit.Enabled = False


cmdCancel.Enabled = True
cmdNext.Enabled = False
cmdPrev.Enabled = False


txtid.SetFocus
End Sub

Private Sub initEditMovie()

txtStatus.Text = "Edit Movie"
'set controls
txtid.Enabled = True
txttitle.Enabled = True
txttheatre.Enabled = True
metprice.Enabled = True


txttime1.Enabled = True
txttime2.Enabled = True
txttime3.Enabled = True
txttime4.Enabled = True
txttime5.Enabled = True
txttime6.Enabled = True
txttime7.Enabled = True

mnuFileSave.Enabled = True
cmdCancel.Enabled = True
cmdNext.Enabled = False
cmdPrev.Enabled = False

txttitle.SetFocus
End Sub


Private Sub addRecord()
Dim movie As movieRecord
Dim recNo As Integer
movie.id = txtid.Text
movie.title = txttitle.Text
movie.theatre = txttheatre.Text
movie.price = metprice.Text

movie.time1 = txttime1.Text
movie.time2 = txttime2.Text
movie.time3 = txttime3.Text
movie.time4 = txttime4.Text
movie.time5 = txttime5.Text
movie.time6 = txttime6.Text
movie.time7 = txttime7.Text

'save record
Open MOVIEFILE For Random As #1 Len = Len(gmovie)
recNo = LOF(1) / Len(movie) 'total records
recNo = recNo + 1

Put #1, recNo, movie
Close #1
'reset controls after saving
initControls

End Sub

Private Sub initControls()
txtStatus.Text = ""
'clear input fields
txtid.Text = ""
txttitle.Text = ""
txttheatre.Text = ""
metprice.Text = ""

txttime1.Text = ""
txttime2.Text = ""
txttime3.Text = ""
txttime4.Text = ""
txttime5.Text = ""
txttime6.Text = ""
txttime7.Text = ""



'set controls
txtid.Enabled = False
txttitle.Enabled = False
txttheatre.Enabled = False
metprice.Enabled = False
mnuEditEdit.Enabled = True
mnuFileSave.Enabled = True

txttime1.Enabled = False
txttime2.Enabled = False
txttime3.Enabled = False
txttime4.Enabled = False
txttime5.Enabled = False
txttime6.Enabled = False
txttime7.Enabled = False



cmdCancel.Enabled = False
cmdNext.Enabled = True
cmdPrev.Enabled = True

getTotalrec


End Sub


Private Sub Form_Activate()
initControls
getTotalrec
End Sub

Private Sub getTotalrec()
Dim movie As movieRecord
'determine the number of records in file
Open MOVIEFILE For Random As #1 Len = Len(gmovie)

gTotRec = LOF(1) / Len(movie)
Close #1

'set the current record no. to 1
If gTotRec > 0 Then
gRecNo = 1
showCurrRecord
End If

txtrecord.Text = Str(gRecNo)
End Sub

Private Sub showCurrRecord()
Open MOVIEFILE For Random As #1 Len = Len(gmovie)
Get #1, gRecNo, gmovie

Close #1

'display record on screen
With gmovie
txtid.Text = .id
txttitle.Text = .title
txttheatre.Text = .theatre
metprice.Text = .price

txttime1.Text = .time1
txttime2.Text = .time2
txttime3.Text = .time3
txttime4.Text = .time4
txttime5.Text = .time5
txttime6.Text = .time6
txttime7.Text = .time7

End With

txtrecord.Text = Str(gRecNo)
End Sub

Private Sub updateRecord()

Dim movie As movieRecord
Dim recNo As Integer
movie.id = txtid.Text
movie.title = txttitle.Text
movie.theatre = txttheatre.Text
movie.price = Val(metprice.Text)

movie.time1 = txttime1.Text
movie.time2 = txttime2.Text
movie.time3 = txttime3.Text
movie.time4 = txttime4.Text
movie.time5 = txttime5.Text
movie.time6 = txttime6.Text
movie.time7 = txttime7.Text



'save record
Open MOVIEFILE For Random As #1 Len = Len(gmovie)

Put #1, gRecNo, movie
Close #1
'reset controls after saving
initControls
End Sub

Private Sub mnuFileExit_Click()
If MsgBox("Are you sure you want to exit without saving?", vbYesNoCancel) = vbYes Then

Unload Me
Load frm_b_main
frm_b_main.Show

End If

End Sub


Private Sub txtShowRecord_Click()

Dim recNo As Integer
Dim movie As movieRecord
Dim gTotRec As Integer

Open "E:/Project/Movie.txt" For Random As 1 Len = 94
recNo = 0
While Not EOF(1) ' Loop while I haven't hit the end of the file
recNo = recNo + 1
Get #1, recNo, movie
Wend
gTotRec = recNo ' reading index records
Close

End Sub

This is what is wrote in the Reservation form to transfer the data over from the Add and Remove form............

Code:
Option Explicit
Private Type movieRecord
id As String * 1
title As String * 20
theatre As String * 1
price As Currency

qtyOnHand As Integer
row As String * 1
number As String * 2

time1 As String * 4
time2 As String * 4
time3 As String * 4
time4 As String * 4
time5 As String * 4
time6 As String * 4
time7 As String * 4

End Type
Private Type reservationRecord
id As String * 1
salesNo As Integer
quantity As Integer
salesDate As Date


End Type
Const RESERVATIONFILE As String = "reservation.txt"
Const MOVIEFILE As String = "movie.txt"

Dim gid As Integer 'keep track of current stock record
Dim gmovie As movieRecord
Dim gsales As reservationRecord


Private Sub getMovieDetail()
Dim found As Boolean
'retrieve stock detail from file and display on screen
Open MOVIEFILE For Random As #1 Len = Len(gmovie)
found = False
gid = 0
Do
Get #1, , gmovie 'get record from file
gid = gid + 1
'if data match, update screen and exit loop
If Trim(gmovie.id) = Trim(cboid.List(cboid.ListIndex)) Then
txttitle.Text = gmovie.title
txttheatre.Text = gmovie.theatre
txtprice.Text = gmovie.price

txttime1.Text = gmovie.time1
txttime2.Text = gmovie.time2
txttime3.Text = gmovie.time3
txttime4.Text = gmovie.time4
txttime5.Text = gmovie.time5
txttime6.Text = gmovie.time6
txttime7.Text = gmovie.time7

cboid.SetFocus
found = True
Exit Do

Miss-Match Data Type
Hi guys,

I have a table with 2 columns. First is called "Name" as text, and second is called "Percent" as number(long integer).

In my VB application, I have two text boxes that I will basically transfer them to the table. How do I do that?

thanks

Finding Match In DATA Combo?
Hi All,

I need to find the closest match in a DataCombo control..

I normally use the SendMessage API for standard combo's, but this doesn't seem to work with data bound combo controls..

Any ideas?

Tweak A SQL Query For VB To Match Data
The below code is pulling data from 2 files based on the planet code matching.  Problem is one file has a 12 digit code and the other has an 11 digit code so no matches.

How would I tweak the below code to only look at 11 digits instead of 12?  This is a large program and I'm thinking this is the area of code that needs to be changed.

Thanks in advance.


sql = "SELECT Planet_Code,Job_Number, Job_Name, format(Mail_Date,'00/00/0000')as Mail_Date , Qty_Mailed, facility_id as zip, date_time as [scan date], Op_code as opcodes,count(*) as [qty scanned] FROM " & USPS_FILE & Chr(44) & EMD_FILE & " WHERE [planet] = [Planet_Code] AND " & SearchCriteria & " GROUP BY Planet_Code,Job_Number, Job_Name, Mail_Date , Qty_Mailed, facility_id, date_time, Op_code order by Planet_Code, date_time"

Searching A Sequential File For A Data Match
I am using a sequential file in VB6 where a user will input values into text boxes (eg txtID - C100, txtName – Jones, txtStatus – Current) and then append the details to a file (code so far).

Private Sub cmdFile_Click()

Dim FileTransfer As String

FileTransfer = txtID & " " & txtName & " " & txtStatus

Open "test.txt" For Append As #1
Print #1, FileTransfer
Close #1

txtRequest = ""
txtName = ""
txtStatus = ""

End Sub

This works fine but, I want to set up another command button where a user will enter a txtStatus value in a separate text box, and then the line details for the first located instance for that status will populate the previous text boxes (or if this is too complicated appear in a label). I also need to know how to locate the next instance for that status.

Any code would be much appreciated, or any sites that could help with my problem. Thanks in anticipation.

Report Sections Do Not Match Data Source
I have the following code to create a DataReport. On the data Report I am using unbound text box's with the data field filled with the name of each field in the database. Every things seems as it should but I get the error "Report sections do match data source". I don't understand why. Can anyone help?


rs.CursorLocation = adUseClient
cn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.path & "datafund.mdb;"
cn.Execute "DROP TABLE rptTable;"
cn.Execute "SELECT Donor.DonorID, Donor.Firstname, Donor.Lastname, Donor.DeliveryAdd, Donor.City, Donor.State, Donations.Date, Donations.Amount into rptTable from donor, donations where donor.DonorID = donations.DonorID AND Donations.Date between #" & VarRptDate1 & "# AND #" & VarRptDate2 & "# ORDER BY Donations.date "

Dim rsreport As ADODB.Recordset
Set rsreport = New ADODB.Recordset

With rsreport
.ActiveConnection = cn
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Open "SELECT * FROM rptTable "
End With

MsgBox rsreport.RecordCount
DataReport1.Orientation = rptOrientLandscape

Set DataReport1.DataSource = rsreport

DataReport1.Show

Report Sections Do Not Match Data Source
My Question is Can I use a Group Header/ Group Footer without using the dataenvirorment.


In my data report I am setting my datasource like this

Private Sub DataReport_Initialize()
Set DataSource = rsPrint

Exit Sub

I found some reasons why the error " the report sections do not match data source error they are." occurs. They are.

(1)The DataReport is bound to an ungrouped recordset.
(my recordset is grouped)

(2)The DataReport was created before binding the recordset.
(done in initialization)

However, every explanation I find to fix this problem uses the dataenvirorment.

Report Section Do Not Match Data Source... Please Help
I am very new to this report stuff. I wrote a code in VB trying to generate a report with grouping but ended in getting error each time I ran the code. I attached the code here hope somebody can help.

Dim db As Database
Private rsAmort As ADODB.Recordset

Set db = Workspaces(0).OpenDatabase _
(App.Path & "MASTERDATA.mdb", False, False, ";pwd=vbairmdb")

Set RS = db.OpenRecordset("MTDATA")
Set Data1.Recordset = RS

txtSQL = "SELECT EQPMTASK.EQPNO,EQPMTASK.EQPNAME,EQPMTASK.MTCODE,EQPMTASK.DATEDUE, " & _
"MTDATA.PERIODICITY, MTDATA.MTTITLE, MTDATA.STATUTORY,EQPGROUP.EQPGRPNAME " & _
"FROM (EQPGROUP INNER JOIN MTGROUP ON EQPGROUP.EQPGRP " & _
"= MTGROUP.EQPGRP) INNER JOIN (EQPMTASK INNER JOIN MTDATA ON EQPMTASK.MTCODE " & _
"= MTDATA.MTCODE) ON MTGROUP.MTGRPNO = MTDATA.MTGRPNO Where " & CAcc & _
" GROUP BY EQPMTASK.EQPNO,EQPMTASK.EQPNAME,EQPMTASK.MTCODE,EQPMTASK.DATEDUE, " & _
"MTDATA.PERIODICITY, MTDATA.MTTITLE, MTDATA.STATUTORY,EQPGROUP.EQPGRPNAME;"

Set RS = db.OpenRecordset(txtSQL)
Set Data1.Recordset = RS

Do While Not Data1.Recordset.EOF
rsAmort.AddNew
rsAmort![EQPT_NO] = Data1.Recordset.Fields(0)
rsAmort![EQPT_NAME] = Data1.Recordset.Fields(1)
rsAmort![MAINT_CODE] = Data1.Recordset.Fields(2)
rsAmort![MAINT_TITLE] = Data1.Recordset.Fields(3)
rsAmort![DATE_DUE] = Data1.Recordset.Fields(4)
Data1.Recordset.MoveNext
Loop

Set MTSCHEDULEGRPX.DataSource = rsAmort

With MTSCHEDULEGRPX.Sections("Section1")
.Controls("txtEQPTNO").DataField = "EQPT_NO"
End With

With MTSCHEDULEGRPX.Sections("Details")
.Controls("txtEQPTNAME").DataField = "EQPT_NAME"
.Controls("txtMAINT_CODE").DataField = "MAINT_CODE"
.Controls("txtMTTITLE").DataField = "MAINT_TITLE"
.Controls("txtDATEDUE").DataField = "DATE_DUE"
End With

MTSCHEDULEGRPX.Orientation = rptOrientPortrait
MTSCHEDULEGRPX.Show



Error - Report Sections Do Not Match The Data Source
Hi All.

I am working on an app where i needed to do some changes to an already working data report that was already made by somebody.

I added a few more column for the report and also to the query that was sent to the report. This query now has a GROUP BY clause also. In the report, i had to add another group and move some of the columns from the details section to the New Group.

The problem is now that when i try to view the report i get an error saying "Report sections do not match the data source".

I am passing the recordset as the Datareport's DataSource.

What am i missing where ?

Thanks in advance.

Resizing Data Grid To Match The Length Of The Column And The Rows
How do I resize a data grid to match the length of the column and the height of the datagrid to match the rows that are dynamically displayed. Any help would be appreciated

POST Data From Excel On A Website And Receive Data Into Excel, Too
Hi there, I have a challenge!

How can I combine the two next scripts so I can POST data to a website (from my Excel) and the data from the called website to be retrieved into a new worksheet?





[POST SCRIPT]

Code:
'**************************************** Post form data - begin
'Data from Excel
Sub test()
Dim CUI as Range
'CUI is a Unique Identification Code for Employers
Set CUI=[A1]
Call PostRequest("http://www.mfinante.ro/contribuabili/link.jsp?body=/contribuabili/agenti_cod.jsp", _
"cod", _
CUI)
End Sub

'sends form fields specified In Names/Values arrays To the URL
Sub PostRequest(URL, Names, Values)
Dim I, FormData, Name, Value

'Enumerate form names And it's values
'and built string representaion of the form data
Name = URLEncode(Names)
Value = URLEncode(Values)
If FormData <> "" Then FormData = FormData & "&"
FormData = FormData & Name & "=" & Value

'Post the data To the destination URL
IEPostStringRequest _
URL, _
FormData
End Sub

'sends URL encoded form data To the URL using IE
Sub IEPostStringRequest(URL, FormData)
'Create InternetExplorer
Dim WebBrowser: Set WebBrowser = CreateObject("InternetExplorer.Application")

'You can uncoment Next line To see form results As HTML
WebBrowser.Visible = True

'Send the form data To URL As POST request
Dim bFormData() As Byte
ReDim bFormData(Len(FormData) - 1)
bFormData = StrConv(FormData, vbFromUnicode)
WebBrowser.Navigate URL, "_Self", , bFormData, _
"Content-Type: application/x-www-form-urlencoded" + Chr(10) + Chr(13)

Do While WebBrowser.busy
' Sleep 100
DoEvents
Loop
'WebBrowser.Quit
End Sub

'URL encode of a string data
Function URLEncode(Data)
Dim I, c, Out

For I = 1 To Len(Data)
c = Asc(Mid(Data, I, 1))
If c = 32 Then
Out = Out + "+"
ElseIf c < 48 Then
Out = Out + "%" + Hex(c)
Else
Out = Out + Mid(Data, I, 1)
End If
Next
URLEncode = Out
End Function
'**************************************** Post form data - end





[RETRIEVING DATA INTO A WORKSHEET]

Code:
Option Compare Text
Option Explicit

Sub DownloadItemFromHTMLpage()
'an example given below - insert the URL you want
'the website' address after POST
Application.Workbooks.Open ("http://www.mfinante.ro/contribuabili/link.jsp?body=/contribuabili/agenti_cod.jsp")
'you will need to know the range to select for the required
'download, or, you can add in a 'Find' function here to search
'for it - the example given below is for a known range...
Range("A40").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
ActiveWindow.Close
End Sub

Adding Data To An Excel Spreadsheet, Deleting Data, Making Calculations, Etc
I'm trying to add data to my excel database using a form that i created.

Database.bmp is my main screen.

Form.bmp is the form that i would like to use to add data to the excel sheet.

Does anybody know the proper way to do this? Should i even be using excel to do this?

I also need to make things that will report Interest over 1 year, add money to accounts, create certificates to print, etc.

How would i initiate a calculator between certain cells?

Is there anyway to make it so that you can double click a cell and edit the invidiual customer?

I need some guidance, Thanks in advance!

How To Change Source Data In Pie-Chart In Excel According To Runtime Data Through Vb
Is it possible to update the sourcedata (number of rows) for pie-chart in excel application thorugh VB.Ifso please let me know.


Thanks

Placing SQL Data In Excel And Then Converting To Graph Data.
The following code is working pretty good at pulling data over into Excel and then making a graph based on the data. My only two complaints is

1.) I want above the actual SQL data that's listed in both column 'A' and column 'B' a header that describes what each column is.

2.) For some reason the graph will not display the first row of data. Everything else listed below row 1 gets placed in the graph.

I think if I could move the data down past row1 when it pulls the data over from recordset to Excel then I could accomplish both 1) and 2)

But I don't understand the code too well since I pulled it from a textbox.

I've got the following in a global module:


Code:
Option Explicit
Public gobjExcel As Excel.Application

Public Function CreateExcelObj() As Boolean
On Error GoTo CreateExcelObj_Err
CreateExcelObj = False
'Attempt to Launch Excel
Set gobjExcel = New Excel.Application
CreateExcelObj = True

CreateExcelObj_Exit:
Exit Function

CreateExcelObj_Err:
MsgBox "Couldn't Launch Excel!!", vbCritical, "Warning!!"
CreateExcelObj = False
Resume CreateExcelObj_Exit
End Function


Public Sub CloseExcel()

If Not gobjExcel Is Nothing Then
gobjExcel.DisplayAlerts = False
gobjExcel.Quit
End If

CloseExcel_Exit:
Set gobjExcel = Nothing
Exit Sub

CloseExcel_Err:
MsgBox "Error # " & Err.Number & ": " & Err.Description
Resume CloseExcel_Exit
End Sub

Then at my command button on my main form I have the following:


Code:
Private Sub cmdSearch_Click()

Dim sMonth As String
Dim sYear As String
Dim rstCount As ADODB.Recordset
Dim fld As ADODB.Field
Dim rng As Excel.Range
Dim objWS As Excel.Worksheet
Dim intRowCount As Integer
Dim intColCount As Integer

sMonth = cboMonth.ListIndex + 1
sYear = frmOrderSelectmonth.cboYear.Text
frmOrderSelectmonth.Hide

Dim adData As ADODB.Recordset 'primary recordset for viewing
Set adData = New ADODB.Recordset

Dim sqTotal As String

If optSales.Value = True Then
sqTotal = "SELECT [tblOrders].[fSalesID], Count([tblOrders].[fOrder]) AS Total From tblOrders Where " & _
"(((Month([fEntrydate])) = '" & sMonth & "') And ((Year([fEntrydate])) = '" & sYear & "')) " & _
"And ([tblOrders].[fVoid] = False) GROUP BY [tblOrders].[fSalesID];"

adData.Open (sqTotal), frmOrderMain.g_cData, adOpenDynamic, adLockOptimistic
If adData.BOF Or adData.EOF Then
MsgBox "No Data found!"
Exit Sub
End If
End If

If optData.Value = True Then
sqTotal = "SELECT fUser, Count([fOrder]) AS Total FROM tblOrders WHERE "
sqTotal = sqTotal + "Month([fEntrydate]) = '" & sMonth & "' And " & _
"Year([fEntrydate]) = '" & sYear & "' And fVoid = False GROUP BY fUser;"
adData.Open (sqTotal), frmOrderMain.g_cData, adOpenDynamic, adLockOptimistic
If adData.BOF Or adData.EOF Then
MsgBox "No Data found!"
Exit Sub
End If
End If


'Display Hourglass
DoCmd.Hourglass True

'Attempt to create Recordset and launch Excel

If CreateExcelObj() Then
gobjExcel.Workbooks.Add
Set objWS = gobjExcel.ActiveSheet
intRowCount = 1
intColCount = 1
'Loop though Fields collection using field names
'as column headings
For Each fld In adData.Fields
If fld.Type <> adLongVarBinary Then
objWS.Cells(1, intColCount).Value = fld.Name
intColCount = intColCount + 1
End If
Next fld
'Send Recordset to Excel
objWS.Range("A1").CopyFromRecordset adData, 500

'Format Data
With gobjExcel
.Columns("A:B").Select
.Columns("A:B").EntireColumn.AutoFit
.Range("A1").Select
.ActiveCell.CurrentRegion.Select
Set rng = .Selection
'.Selection.NumberFormat = "$#,##0.00"
'Add a Chart Object
.ActiveSheet.ChartObjects.Add(135.75, 14.25, 607.75, 301).Select
'Run the Chart Wizard
.ActiveChart.ChartWizard Source:=Range(rng.Address), _
Gallery:=xlColumn, _
Format:=6, PlotBy:=xlColumns, CategoryLabels:=1, SeriesLabels _
:=1, HasLegend:=1, Title:="Number of orders assigned to Salespeople", CategoryTitle _
:="", ValueTitle:="", ExtraTitle:=""
'Make Excel Visible
.Visible = True
End With
Else
MsgBox "Excel Not Successfully Launched"
End If


DoCmd.Hourglass False

cmdCreateGraph_Exit:

Set rstCount = Nothing
Set fld = Nothing
Set rng = Nothing
Set objWS = Nothing
DoCmd.Hourglass False

End Sub

Whether you're dealing with SalesID or User's total count
It would look like this in the queries:

Stephen 24
Jesse 18
Frank 10
Amber 17

I just want to place above that data the headers in Excel:

Name Total
Stephen 24
Jesse 18
Frank 10
Amber 17

then it would work great.
Any help is appreciated!
Thanks

Modifying Excel Data Using Data Control Object
This is a re-post of a previous message with a new wrinkle.

I am creating a form filled with text boxes. These text boxes will contain values that are also cell values of an Excel spreadsheet. I have included a Data Control object on the form that points to the Excel spreadsheet. Each of the text boxes on the form points to a particular field (cell) in the spreadsheet through it's DataSource / DataField properties. The Excel file contains only 2 rows of information. The 1st row is the data description, and the 2nd row contains the data. I have discovered that when I change the values in the text boxes, the corresponding cell values in the Excel spreadsheet do not change. If I then close the VB application, the Excel values are updated. My question is: how do I "force" the Excel worksheet to be updated without closing the VB application?

Transfering Data Form A Data Grid To Excel
Hi guys.

I have a program in VB6 which load data from an access table into a data grid, now I need to trasfer that data in the grid to an excel sheet. How can I do this?.

Thanks in advance

Excel - How To Get Formatted Data, Not Original Data Through Code
Hi all,

I am reading through an excel column, and I need to get a number from each cell. However, I don't want the original number i.e. 65.382745, I want the number the user has specified by defining the number of decimal places i.e. 2 places 65.38, 3 places 65.383.

I am currently using the sheetname.cells(row,col) property to get at the data, how do I get the formatted data?

TIA



Noogle

Edited by - original_noogle on 10/6/2003 7:59:13 AM

Extract Data From/write Data To Excel?
Hi
I'm making a program in VB which needs to get & give data to an Excel-sheet. However, I don't know how to copy data to and from an open Excel-workbook :S
Can you guys help me?

Convert Excel Data To Access Data With VB 6.0
Hello Gurus,
I want to add data presently existing in Excel 2000 into an Access / SQL-2005 database.
Can any one please help?
Thanks
GeoNav

Type-declaration Character Does Not Match Declared Data Type
Type-declaration character does not match declared data type?
I don`t get it
This error message appears and Left$ is marked in the code, I guess it has something to do with types, but what?
Please help



Code:
Open Sti & "DeaktiverteDager.txt" For Input As #1
While Not EOF(1)
Line Input #1, LinjeITekstFil
LinjeLengde = Len(LinjeITekstFil)
RestAvLinje = LinjeLengde - 2

If Left$(LinjeITekstFil, 1) = Left$(label10.caption) Then
For i = 0 To 4
If Mid$(LinjeITekstFil, 3, RestAvLinje) = Label3(i).Caption Then
Label3(i).Visible = False
Label5(i).Visible = False
Text1(i).Visible = False
Text2(i).Visible = False
Command1(i).Visible = False
Command2(i).Visible = False
List1(i).Visible = False
List2(i).Visible = False
End If
Next
Wend
Close #1

"Report Sections Do Not Match Data Source"
Hi Everyone,

Could someone help me out here...

I am using Data Environment and Data Report. I was thinking of placing some report text fields in the GROUP HEADER so that my data only appears once. i am getting the error message "Report Sections do not match data source" even before I add any text fields. Please help out! Thank you!

Tim

Type-declaration Character Does Not Match Declared Data Type
I am getting compiler error "type-declaration character does not match declared data type" . It's highlighting Left$
LVGetItemText = Left$(objItem.Text, nRet)

Derclarations are as below.
VB Code:
Private Type LV_ITEM   Mask As Long   Index As Long   SubItem As Long   State As Long   StateMask As Long   Text As String   TextMax As Long   Icon As Long   Param As Long   Indent As LongEnd Type Public Function LVGetItemText(lParam As Long, hwnd As Long) As String   Dim objItem As LV_ITEM   Dim nRet As Long   'some code   If nRet Then      LVGetItemText = Left$(objItem.Text, nRet)   End Ifexit function

Serial Data In, Data Out To Excel Help
I need help getting serial recieved data from VB 6.0 into an Excel spreadsheet. I can get the data in with no problem but do not know how to get it into Excel. The spread sheet needs to be up to 26000 rows by 10 colums. I can get the number of rows it that helps. What I want to do is:

open the worksheet
bring in a serial data (integer)
put it into the correct Excel cell
get the next data

save and close the spreadsheet

This is my first atempt at using VB and Excel.

Thanks for the help.

How To Get The Data From A Excel Sheet And Use The Data.
This is a multi-part message in MIME format.

--------------InterScan_NT_MIME_Boundary
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_01AC_01C15D7E.BEC52C60 "

------=_NextPart_000_01AC_01C15D7E.BEC52C60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi

I want some help , I'm new and it is many years since I haveprogramming.
And now I want to learn, and I know the best way is to try and fail.
So I have start on a project where I will read a EXCEL Sheet with 4colums
and I want to have a window with 4 text boks.And if I search for anumber or


a word in one of them it will take what is in the row and fill in theother 3.
Anyone that can help me ?



The sheet is like this



column 1 column 2 column 3 column 4

400000 This is a test L-12345 The test is goingwell



Thank you everyone

------=_NextPart_000_01AC_01C15D7E.BEC52C60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1"http-equiv=Content-Type>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>I want some help , I'm new and it ismany years


since I have programming.</FONT></DIV>
<DIV><FONT face=Arial size=2>And now I want to learn, and I know thebest way is


to try and fail.</FONT></DIV>
<DIV><FONT face=Arial size=2>So I have start on a project where Iwill read a


EXCEL Sheet with 4 colums</FONT></DIV>
<DIV><FONT face=Arial size=2>and I want to have a window with 4 textboks.And if


I search for a number or </FONT></DIV>
<DIV><FONT face=Arial size=2>a word in one of them it will take whatis in the


row and fill in the other 3.</FONT></DIV>
<DIV><FONT face=Arial size=2>Anyone that can help me ?</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>The sheet is like this</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>column 1      


column 2        column 3   
    column 4</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>400000       This is


a test        L-12345   


    The test is going well</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Thank youeveryone</FONT></DIV></BODY></HTML>

------=_NextPart_000_01AC_01C15D7E.BEC52C60--



--------------InterScan_NT_MIME_Boundary--

Fill A Vba Form With Excel Workbook Data, Updating This Wrkbook W/ Data From The Form
Okay I have a basic to intermediate understanding on using vba and Excel utilities. I need help with the workflow of my application rather than specific procedures.
I've got data on only one worksheet where each record is defined by an account id. Every cell on each record is populating a specific textbox on a form. The form is a basic interface for users, moving from one record to next. So mostly the data will flow from the worksheet to the form with the exception of one field for each record. The user will update that field as needed on the form. There are only 30 records or so on the worksheet. I can't rationalize learning Access and/or some database connection since there are only a few records and few fields.

This is an example of the field headers and one record:
Account Id, Account Name, Total Balance, Past Due Balance, Status
011,ChevyChaseAccount,$1200,$100,Customer sent in check (not posted).

I can think of only one way to update the form with the data and that is piece by piece:

Code:
Private Sub UserForm_Initialize()
With frmDetail
'.txtAccountName = ActiveSheet.ActiveCell.Offset(0, 2).Value (this gives me an error since I can't use the offset property for the code in forms)
.txtAccountName = ActiveSheet.Range("B2").Value (since I can't use offset then I have to resort in a specific address)
.txtAccountId = ActiveSheet.Range("C2").Value (since I can't use offset then I have to resort in a specific address)
.txtTotalBalance = ActiveSheet.Range("D2").Value (since I can't use offset then I have to resort in a specific address)
End With
End Sub

I haven't thought of a way to move from one record to another let alone how to update that one field to another.
Let me know if you have any questions,
Thanks,
Aaron

If I Save A Text File (data Crlf Data Crlf...) As Excel,
it will open fine unless i got some numeric entries starting by zero(s).... i will lose the leading zeros.

same problem if the entry is a 16 or more digits number...
my data will be formatted like.. 1.4325etc E10...instead 14325etc

adding an leading unserscore is not a solution...

see what i mean ?

Dynamic Array-Add Data Check Data, Sort Data
Not sure really how to do this.
Got a column of numbers, some may be double.
want to check each number from the column
if its in the array go to next if not add it to the array
Then sort when done.


was reading and found arraylist and all sorts of stuff. kinda confused.

How should i declare the array?
Can i pass the array into a function
how do i find the length of the array

dim ItemsArray() as integer

Invalid Data In Excel Spreadsheet/count Group Of Items In Excel Sprdsh
Please help:
Problem#1:
I populated an excel spreasheet with data from access table, using CopyFromRecordset function.  The process was successful and all the fields displayed correctly in the spreadsheet, except the date field which displayed:"########".  What did I do wrong?

Problem#2:
What vb code can I used to count group of items in the spreadsheet.
Any insight will be very helpful.
Thanks,
C.

Can I Query Data From Multi Excel Tables And Insert Them Into Another New Excel Table
Hi everyone,

Can I query data from multi excel tables and insert them into another new excel table via VC?

i.e. I have excel table A, and excel table B, they have one same column "num"

I hope I can join these two tables into one new excel table via this public coulmn, all the steps should be finished via VC (please tell me if you have other suggestion about the program tool ^_^)

Seems that the function of "Microsoft query" in the Excel is OK, But I hope I can do a good UI and user don't need to write sql by himself, so it is better if you can tell some reference about how to query from muti-tables (I think it should be muti-datasource) and insert this result to another excel table,Thanks a lot :-)

AND how to implement it? please give me more doc if it is possible, Thanks!

I'm not familar with sql syntax about excel, could you please tell more about this? thanks!


Thanks
Lindsay

Excel-VBA Q: Mill's Posting Excel 101: Filtering Data Using Multiple Combobox
Sub: Excel-VBA Q Mill's posting Excel 101: filtering data using multiple combobox - how to indirectly reference the

I joined this group yesterday. Thanks to all who are actively participating. I read Mill's posting 'Excel FAQ - Excel 101 ' ; thanks for the sample code.

I love Excel, and has been using it for 7 years - good at formula, macros etc, not programming with VBA. Now I want to venture into that area. The last time I used VB was in 1998 - VB5, worked just on one project. I am good at OOA, OOD, and have done C++ programming.

I have a question with reference to the code found in the Lesson 3 - Having items in one ComboBox filter items in another ComboBox.

In the FilterList() subroutine, could I indirectly specify the argument for the Case statement through a cell reference instead of directly specifying it in the subroutine.
e.g.
Select Case strCompany
Case $D$1

Select Case strCompany
Case "Apple"


Actual code from Mill's posting:

Sub FilterList()

Dim strList As String, strCompany As String, strEmployee As String

On Error GoTo FilterListError

strCompany = Range("B1").Text

Select Case strCompany
Case "Apple"
strList = "=$F$2:$F$6"
Case "IBM"
strList = "=$G$2:$G$4"
Case "Microsoft"
strList = "=$H$2:$H$4"
End Select

Regards & Thanks

How To Import Excel Data From A Closed Excel File To Access Table?
Hi friends,
i have the following Excel sheet

     A B
1 BILL PAID
2 CM20 650.00
3 CM32 1750.12


 I want to import the same data into an Access table with the same field name.

Any help?

Thankx and regards

Haris


_____________________________________________________________________


Edited by - harisraz on 6/18/2006 1:33:00 AM

What Is The Best Way To Save Data As Excel File If I Don't Know User's Excel Version?
do i want to query their version of excel then load
corresponding libraries...

thank you

Excel && VB (search For Match)
I managed to do this without using datagrid/flexgrid/any grid of any kind. I successfully ran this program, however encountered one small problem or might be normal if at all, it took a while for it to find an answer then produce an output, almost like computer "frozen". Is there any better way to write this programming?

Sample Excel sheet:

Data Item1 Item2 Item3
Sean 1 1
Kim 1 1
Jacob 1 1

The data I have consist more than 1,000 cells filled in but above is the concept I'm going to do. Below is the code.

Dim i, j
    Set db = OpenDatabase(App.Path & "/datasheet.xls", False, False, "Excel 8.0;")
    Set datash = db.OpenRecordset("SELECT * FROM [data$]", dbOpenDynaset)
With datash
.MoveFirst
i = 1
     Do While i <= .RecordCount
     j = 0
          Do While j < .Fields.Count
               If .Fields("data").Value = datalist.Text Then
                         If .Fields(j).Value = "1" Then
                              data1list.AddItem .Fields(j).Name
                         End If
               End If
               j = j + 1
           Loop
           .MoveNext
            i = i + 1
      Loop
End With

Thanks in advanced. Sean

Sean

(URGENT) Simple Search - Match Any Word / Match All Words ?
Can anyone help me alter my code so that it searches for:

-Match any word

-Match all words

At the moment my code is only matching either the first word or exact strings, so its pretty poor.


My code so far is:

Code:
newMatchRS.Open "SELECT * From Task WHERE UCase(TaskInformation)
LIKE '%" & UCase(txtSearchCriteria) & "%' Order By TaskID", db,
adOpenStatic, adLockOptimistic

I havent got a lot of time for any messing with getting code to work, so anyone that has any quick help tips would be very appreciated

(URGENT) Simple Search - Match Any Word / Match All Words ?
Can anyone help me alter my code so that it searches for:

-Match any word

-Match all words

At the moment my code is only matching either the first word or exact strings, so its pretty poor.


My code so far is:
Code:
newMatchRS.Open "SELECT * From Task WHERE UCase(TaskInformation)
LIKE '%" & UCase(txtSearchCriteria) & "%' Order By TaskID", db, adOpenStatic, adLockOptimistic



I havent got a lot of time for any messing with getting code to work, so anyone that has any quick help tips would be very appreciated

Write Data To Pocket Excel Or Excel 2000?
Hi,

I'm working on a nifty little counting program that will insert its data into an Excel 2000 worksheet... I know that in Excel 2000 you can use it's built in version of VBA to do it....

Private Sub Hotkey_Click()
Dim counter As Single
counter = Count.Caption + 1
Count.Caption = counter
Cells(7, 11) = Count.Caption <---see right there...
ActiveWorkbook.Save <---Look, I'm saving the data...
End Sub


Private Sub UserForm_Activate()
Count.Caption = 0
End Sub

Now this works fine for a PC but I would like to make a version of this counter using eVB, is there any way I can export data to an excel 2000 worksheet on a network drive?

Thanks,

ERic

Exact Match In Excel Cell
Hi,

I am developing an application that searches thru the cells [data] of an excel sheet. I 'm using the .Find method and things were going well, till I realized that .Find method searches for the first occurance of the search string.

What I want to do is to search for the exact match. Can anyone help me with this? Thanks.

In case, you didnt get it, it's like this.

I want to search for cell containing number 4748. But before that there's another cell with the number 9885744748. When i use .Find method, this long number returns too. I want to search for exact match, i.e. in this case, 4748.

Thanks once again.

voids.

Retrieving Row Number From Excel On Match
hello all,
I have the following code:


Code:
Sub Find_Matches()
Dim Match As Variant, CompareRange As Variant, x As Variant, y As Variant
'Set CompareRange equal to the range to which you will
'compare the selection.
'Set CompareRange = Range("C1:C10")
'Note: If the compare range is located on another workbook
'or worksheet, use the following syntax.
'Set CompareRange = Worksheets("Sheet2").Range("C1:C10")
Set CompareRange = Range("c1:c10")
'
'Loop through each cell in the selection and compare it to
'each cell in CompareRange.
'
For Each x In Selection
For Each y In CompareRange
If x = y Then
Match = CompareRange.Rows:
x.Offset(0, 1) = Match
Else
Match = ""
End If


My problem is that when it gets a match, it always returns 1 as row number.
Here is my output with columnA being my Selection and columnB holding the
results:

Code:
row columnA columnB columnC
1 1 1 1
2 2 1 4
3 3 6
4 4 1 1
5 5 0
6 6 1 a
7 7 1
8 8 1 2
..
..

Any idea how I can return actual row number?
Thanks very much!

2 Excel Workbooks Match, And Copy
Currently, I have 2 excel workbooks.

Workbook 1: contains 1 tab (worksheet) generated by a macro to formatt data and name the tab as the month (ie 1,2,3,).

Workbook 2: contains summary tabs (worksheets) that draw on information from monthly data which are in tabs named by month (ie 1,2,3).

Currently, I am copying and pasting from Workbook 1 into workbook 2 to correctly match the months.

I would like a macro to be able to match the name of the tab in workbook 1 to one of the 12 months listed in workbook 2 and paste the information from workbook 1 to 2, into the matching tab.

I would be greatful if someone could figure this out for me. I am still learning VBA. Thanks!

Excel: Dealing With #N/A Returned From Match In VBA
Ok after an hour of trying to figure this out, here goes:

Code:For I = 0 To UBound(TextArray)
    Debug.Print "I: " & I
    Debug.Print "TextArray(I)" & TextArray(I)
    For X = 0 To UBound(RangeArray)
    Debug.Print "X: " & X
    Debug.Print Application.WorksheetFunction.Match(TextArray(I), RangeArray(X), 0)
    If (Application.WorksheetFunction.IsNA(StatMatch)) Then
    Debug.Print "NotAvail"
    End If
    Next X
    Debug.Print "StatMatch " & StatMatch
Next I


Alright here is a tip of code I have been playing with.

A "simple" nested for loop (admittedly I could probably change the inner loop to another type).

Basically it goes through I number of parameters in TextArray, it attempts to match each one
to a second set of lists with the inner for loop by using the Excel Match function.

Now in each instance the inner for loop is bound to hit "#N/A" because something is only going
to match one thing in RangeArray if even that. The problem with it is a return of that seems to
immediately halt code execution without any explanation.

I need some way to handle getting back #N/A (or whatever error it really is) and dealing with it
within the scope of the code.

I'm a bit stumped.

Suggestions ?

How Can I Put In The Same Line Three Column That Match In VB Excel
i have a files with 8 columns that are respectivly:
( JOB NO., ID, ETC, EAC, Network, Forecast)

Id is linked to the ETC and EAC and the network is linked to the Forcast

i would like to take all the JOB NO compare them with the IDs and the Networks if they matche (they are exactly the same) take the ETC<EAC and Forcast put then on hte same line as the coresponding Job number

and for all the ID and Network that does not match with the Job number delete row.

it is a axcel file and i would like to do it in VB excel

Thanks

for any more question please ask me

Fill A Vba Form With Excel Workbook Data, Updating The Same Workbook W/ Data From The Form
Okay I have a basic to intermediate understanding on using vba and Excel utilities. I need help with the workflow of my application rather than specific procedures.
I've got data on only one worksheet where each record is defined by an account id. Every cell on each record is populating a specific textbox on a form. The form is a basic interface for users, moving from one record to next. So mostly the data will flow from the worksheet to the form with the exception of one field for each record. The user will update that field as needed on the form. There are only 30 records or so on the worksheet. I can't rationalize learning Access and/or some database connection since there are only a few records and few fields.

This is an example of the field headers and one record:
Account Id, Account Name, Total Balance, Past Due Balance, Status
011,ChevyChaseAccount,$1200,$100,Customer sent in check (not posted).

I can think of only one way to update the form with the data and that is piece by piece:
Code:Private Sub UserForm_Initialize()
    With frmDetail
        '.txtAccountName = ActiveSheet.ActiveCell.Offset(0, 2).Value (this gives me an error since I can't use the offset property for the code in forms)
        .txtAccountName = ActiveSheet.Range("B2").Value (since I can't use offset then I have to resort in a specific address)
        .txtAccountId = ActiveSheet.Range("C2").Value (since I can't use offset then I have to resort in a specific address)
        .txtTotalBalance = ActiveSheet.Range("D2").Value (since I can't use offset then I have to resort in a specific address)
    End With
End Sub

I haven't thought of a way to move from one record to another let alone how to update that one field to another.
Let me know if you have any questions,

Error 1004 In Method Match [Excel VBA]
Code:
For n = 2 To intLRFinding
        intActRMA = oNew.Range("X" & n)
        If IsNumeric(intActRMA) Then
            strActRMA = str(intActRMA)
        Else
            strActRMA = intActRMA
        End If
        intRMA = Application.WorksheetFunction.Match(strActRMA,MyWORKSHEET.Range("A2:A" & intLRFinding), 0)
    Next n


This part generates error 1004, in the line :
intRMA = Application.WorksheetFunction.Match(strActRMA,MyWORKSHEET.Range("A2:A" & intLRFinding), 0)




Edited by - Geof on 9/6/2006 5:45:32 PM

Copy Excel Data To New Excel Workbook HELP!
I have a excel workbook with thousands of peoples names and info. A persons record can be in the workbook more than once. I want to create a macro or somthing in excel to copy all of the same people with the last name Smith for example to a new workbook. How do I go about doing this, anyone with example code or help.

Thanks

Data To Excel
Hi, how I can send data directly to excel, without a comma-delimited file, only send data and formatt to a cell. ?

Thanks !!

Copyright © 2005-08 www.BigResource.com, All rights reserved