[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

creating a Excell worksheet from Vb

Posted on 1999-11-22
9
Medium Priority
?
199 Views
Last Modified: 2010-05-02
Hello
I want to create a new excel worksheet dynamically from within my application.What I need to do is hand in Product name ,barcode  and a quantity field .Also I have to hand in a formula for a quantity total Does any body have a sample which could show me how this is done.
Regards T
0
Comment
Question by:visualbasic
9 Comments
 
LVL 3

Expert Comment

by:manojamin
ID: 2225888
0
 
LVL 1

Expert Comment

by:jflemin
ID: 2226036
Dim ExcelApp As Excel.Application
    Dim ExcelBook As Excel.Workbook
    Dim ExcelSheet As Excel.Worksheet
   
    Screen.MousePointer = vbHourglass
    Set ExcelApp = New Excel.Application
        Set ExcelBook = ExcelApp.Workbooks.Add
            Set ExcelSheet = ExcelBook.Worksheets.Add(, , , xlWorksheet)
                ExcelSheet.Cells(1, 1).Value = "Added through VB"
                ExcelSheet.Name = "My Sheet Name"
                ExcelSheet.SaveAs "C:\Temp\VbExample.Xls"
            Set ExcelSheet = Nothing
        ExcelBook.Close
        Set ExcelBook = Nothing
    ExcelApp.Quit
    Set ExcelApp = Nothing
    Screen.MousePointer = vbNormal
0
 
LVL 3

Expert Comment

by:manojamin
ID: 2226078
jflemin,
Basically it same as the link I provided...

visualbasic,
jflemin code is fine, if you want to put formula in A2 replace following line

ExcelSheet.Cells(1, 1).Value = "Added through VB"

with

ExcelSheet.Cells(1, 1).Value = "0"
ExcelSheet.Cells(2, 1).Formula = "=A1 + 1"

This way, you will have value 0 in A1 and value 2 in A2

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Expert Comment

by:eyaltil
ID: 2228240
Code as above
0
 
LVL 3

Expert Comment

by:manojamin
ID: 2228266
eyaltil,

what was that about???
0
 

Author Comment

by:visualbasic
ID: 2229132
: manojamin
Could you mail me an wed so I can give you the 100 points
0
 
LVL 3

Expert Comment

by:manojamin
ID: 2229156
an wed?

what is that?

How do I mail you? I don't have your e-mail address!

I guess you will have to reject eyaltil answer in order for me to provide you answer!!

0
 
LVL 3

Expert Comment

by:manojamin
ID: 2229206
an wed?

what is that?

How do I mail you? I don't have your e-mail address!

I guess you will have to reject eyaltil answer in order for me to provide you answer!!

0
 
LVL 3

Accepted Solution

by:
manojamin earned 400 total points
ID: 2232605
Here is the answer to get the points!!

jflemin,
Basically it same as the link I provided...

visualbasic,
jflemin code is fine, if you want to put formula in A2 replace following line

ExcelSheet.Cells(1, 1).Value = "Added through VB"

with

ExcelSheet.Cells(1, 1).Value = "0"
ExcelSheet.Cells(2, 1).Formula = "=A1 + 1"

This way, you will have value 0 in A1 and value 2 in A2



0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question