Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default My code replace the data by the line number

Copyfromrecordset puts the recordset on the worksheet. It is a single
command. I have never seen any post here that says it adds stray data at
the end. If this is all that is on the worksheet, try

Rg.Parent.UsedRange.Clear

or Rg.Parent.UsedRange.Offset(19).Clear

if you don't want to clear above row 10 (assumes Usedrange starts in A1,
but it may not. You need to check).

--
Regards,
Tom Ogilvy


keawee wrote in message
...
Hello, I have a problem in a recordset.

I recover of the data since Access and I insert my data in Excel. I
place my data in A11 for example and imagine that my data go from A11
to R51. With each time, in my column A with last the recordings it me
insert not data but the number of the line, in this case 51.

I have only this problem that in a cell and the first column of my last
recording. Could you help me?.

This is my code

Public Sub CopyFromRecordset()
Dim Db1 As Database
Dim Rs1 As Recordset, Nb As Long
Dim Sh As Worksheet, Rg As Range, Nl As Range
Dim Chemin As String, Fichier As String

Dim bordure As MsoLineStyle

bordure = msoLineSingle

Set Sh = Worksheets("Test")
With Sh
Set Rg = .Range("A10")
End With

Set Db1 = DBEngine.OpenDatabase(ThisWorkbook.Path
& "\GeneralReport.mdb")

Set Rs1 = Db1.OpenRecordset("REPORT", dbOpenDynaset)

Rg.CurrentRegion.Clear

If Rs1.EOF = False Then

Nb = Rs1.Fields.Count - 1

For a = 0 To Nb
Rg(, 1 + a) = Rs1.Fields(a).Name
Next

Rg.Resize(, Nb + 1).Font.Bold = True
Rg.Resize(, Nb + 1).Interior.ColorIndex = 15


Rg.Offset(1).CopyFromRecordset Rs1

Else
MsgBox("No Record")
End If

After I kill the object
...

Thanks for your help

Keawee



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



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
Macro code to put series name next to individual line in line grap Otani Charts and Charting in Excel 3 February 23rd 10 07:24 PM
Excel 2007 Line Graph, Data Table, Number Formatting Paul Charts and Charting in Excel 5 November 8th 08 04:13 PM
If statement to replace #VALUE! code jeannie v Excel Worksheet Functions 8 June 27th 07 03:53 AM
Graphically display data on a number line ChuckK Charts and Charting in Excel 1 October 17th 06 07:08 PM
Combination Bar/Line chart---each with different number of data points Mr Jones Charts and Charting in Excel 0 June 17th 06 06:43 PM


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