3 Replies - 945 Views - Last Post: 07 October 2019 - 12:24 AM Rate Topic: -----

#1 Sam1961   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-October 19

excel sheet range selection

Posted 01 October 2019 - 09:44 AM

I want to transfer the data from vb6 form to excel sheet.
I am puzzled on how to select the worksheet first, then the cell/range let say A1 which is the header. For example FNAME
After this selection count the row to find the empty row so that the textbox value goes in that immediate cell i.e., A2

Dim eExcel As Object
Dim eBook As Object
Dim eSheet As Object
Set eExcel = CreateObject("Excel.Application")
Set eBook = eExcel.Workbooks.Add


'Add data to cells of the first worksheet in the new workbook
Set eSheet = eBook.Worksheets(1)
eSheet.Range("A1").Value = "FNAME"
eBook.worksheet(1).RANGE("a1").SELECT
FROM HERE IF THIS IS CORRECT WHAT TO DO

Kindly assist

Sam

Is This A Good Question/Topic? 0
  • +

Replies To: excel sheet range selection

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15728
  • View blog
  • Posts: 63,014
  • Joined: 12-June 08

Re: excel sheet range selection

Posted 01 October 2019 - 10:05 AM

What have you tried, thought about, or considered?

Have you peeped at this tutorial?
https://www.dreaminc...visual-basic-6/
Was This Post Helpful? 0
  • +
  • -

#3 Sam1961   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-October 19

Re: excel sheet range selection

Posted 03 October 2019 - 07:53 AM

Yes, I have gone through with the code earlier.
I was actually thinking on how to select the sheet
at the first, then the range and thereafter run
the counter.
Let me give a try if succeeded then great otherwise please help me.
Sam

Sorry for the grammar,
Yes I gone through the code. .........
Was This Post Helpful? 0
  • +
  • -

#4 Sam1961   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-October 19

Re: excel sheet range selection

Posted 07 October 2019 - 12:24 AM

Hi again.
Following is the coding I tried but getting an error on opening the file
"File couldn't be found" whereas the file is on desktop.
For your attention code is copied below please guide where the mistake lies if any
=========
Private Sub Command1_Click()
Dim excelApp As Excel.Application
Set excelApp = CreateObject("Excel.Application")

Dim excelWB As Excel.Workbook
Set excelWB = excelApp.Workbooks.Open("c:\USERS\HP\DESKTOP\WORKBOOK11.XLSX")

excelApp.Visible = True
'Dim lastrow As Range

Dim excelWS As Excel.Worksheet
Set excelWS = excelWB.Worksheets(1)
excelWS.Range("A1") = "NAME"
excelWS.Range("a2") = "AMIR"
excelWS.Range("a1").Select
ActiveCell.End(xlDown).Select
lastrow = ActiveCell.Row
Cells(lastrow + 1, 1).Value = Text1.Text





'rowCount = excelWS.UsedRange.Rows.Count

'colCount = excelWS.UsedRange.Columns.Count



' One way to search for things

'For r = 1 To rowCount

'For c = 1 To colCount

'If excelWS.Cells(r, c).Value = "Using ranges with cell strings" Then

' Store the row number, and column number in a variable

'foundRow = r

'foundCol = c

'excelWS.Cells(r, c).Value = "I found you!"

'End If

'Next c

'Next r

End Sub
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1