Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

First post please help... excel problem...

Judo TomJudo Tom Member Posts: 1
Hello,

GREAT BOARD!!! lots of good info.. how active is the vb forum??

anyway.. im having a bit of an excel problem.

I am using textboxes to populate cells in a work sheet.. my only problem now is that for some reason the workbooks are not always opening on the first page like they were on my computer... so i need to make sure i paste info onto the correct worksheet

this is the code i was using:

With objExcel ' Use With...End With so you don't have to type objExcel over and over again

' Open your workbook
.Visible = True
.Workbooks.Open(FileName:="c:p4y.xls")

End With


With objExcel

.Cells(1, 3) = TextBox1.Text ' bank name

this would open excel and then paste the data for me.. but if excel opens the book on a different worksheet.. not the first one im screwed...

how can i modify the cells statement to always paste to a certain worksheet or how can i make sure that the workbook always opens to the first worksheet??

thanks for the help
Tom

Comments

  • RSlaydenRSlayden Member Posts: 22
    : Hello,
    :
    : GREAT BOARD!!! lots of good info.. how active is the vb forum??
    :
    : anyway.. im having a bit of an excel problem.
    :
    : I am using textboxes to populate cells in a work sheet.. my only problem now is that for some reason the workbooks are not always opening on the first page like they were on my computer... so i need to make sure i paste info onto the correct worksheet
    :
    : this is the code i was using:
    :
    : With objExcel ' Use With...End With so you don't have to type objExcel over and over again
    :
    : ' Open your workbook
    : .Visible = True
    : .Workbooks.Open(FileName:="c:p4y.xls")
    :
    : End With
    :
    :
    : With objExcel
    :
    : .Cells(1, 3) = TextBox1.Text ' bank name
    :
    : this would open excel and then paste the data for me.. but if excel opens the book on a different worksheet.. not the first one im screwed...
    :
    : how can i modify the cells statement to always paste to a certain worksheet or how can i make sure that the workbook always opens to the first worksheet??
    :
    : thanks for the help
    : Tom
    :
    I added the following line before the .cells assignment:
    .Sheets(1).Activate
    and it seems to work. That was very quick and dirty testing, but may keep you going.
  • Shawn CarterShawn Carter Member Posts: 0

    ________ || http://forcoder.org || free video tutorials and ebooks about < Swift Visual Basic .NET Visual Basic C++ Scratch JavaScript C# MATLAB PHP Delphi Perl Ruby Go C Python PL/SQL R Objective-C Java Assembly Fortran Transact-SQL Alice Rust Julia Hack ABAP Lisp Logo COBOL Kotlin FoxPro Crystal Apex Erlang Awk D Lua ML Clojure Prolog Scheme LabVIEW Dart Bash VBScript SAS Ada F# Scala /> ________

Sign In or Register to comment.