VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



From Vb to Excel, some simple manipulations

by Steve (12 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 21st July 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

From Vb to Excel, some simple manipulations

API Declarations


'Dim worksheet3 As Worksheet

Rate From Vb to Excel, some simple manipulations



I'm game ! How about you?
-----------------------------------
PS This is much cleaner code than that which I 
put forth earlier !!
----------------------------
PSS.  Does Anyone know how to launch more than
one Worksheet at the same time inside this program?
----------------------------
PSSS.  Watch out !  This text file did not put everything on the 
correct line !


Private Sub Command1_Click()

Set Excel = New Excel.Application
Set Workbook = Excel.Workbooks.Add
Excel.Visible = True
Set Worksheet1 = Workbook.ActiveSheet

Worksheet1.Rows.Cells(1, 1) = "The First Cell "
For x = 2 To 9

Worksheet1.Rows.Cells(x, 2) = x  ' Create a fill
Next x

Rem  Modify that fill

Worksheet1.Rows.Cells(4, 2) = 88
Worksheet1.Rows.Cells(4, 4) = 99 & " Test Concatenation"

myvariable = Worksheet1.Rows.Cells(4, 2)
Rem Change Label attributes

Label1.FontBold = True
Label1.FontSize = 18
Label1.BackColor = vbRed
Label1.Caption = myvariable

Rem This next line will place a value of 700 in Cell 2,2
Rem  even though the auto text does not recognize the dot
Rem after ()
Worksheet1.Cells(2, 2).Value = 700

Rem  This works !!!!!!

Worksheet1.Cells(2, 2).Font.Bold = True
Worksheet1.Cells(8, 2).Font.Color = vbRed
Worksheet1.Cells(5, 2).Font.Size = 24

Rem The following does not work

'Worksheet1.Cells(6, 2).FillColor = vbGreen
'Worksheet1.
Rem   ----   This works-- You can insert Excel's functions


Rem  ---  This is a Vb Function This works

Worksheet1.Cells(10, 4) = Now()
Worksheet1.Cells(11, 2) = "=" & "IsText(A1)"
'Worksheet1.Cells(15, 2) = "=" & "CONCATENATE(This is the sum of B2:B8 -> ,(B3:B8))"
Worksheet1.Cells(15, 2) = "=" & "sum(B3:B8)"
Worksheet1.Cells(16, 2) = "Applle"   ' Create a misspelled word

Rem  You now have a method to access a spellchecker.
Rem  For your projects
Rem  The dialog box comes up and allows you to
Rem   correct the mispelled word

Worksheet1.Cells(16, 2).CheckSpelling   '

Rem  Trasfer a cell's value to a label on your form
Label2.Caption = Worksheet1.Cells(16, 2)


Rem Don't do the next line it fills the entire sheet sith sin(45)
'     Worksheet1.Rows.Cells.FormulaR1C1 = Sin(45)
End Sub

Private Sub Form_Load()
Rem You will get error " User Definded type not definded
Rem  if you don't Go to Project / References/ Microsoft
Rem  Excel 9 Object Library
Rem You will get error 'Expected variable not Project if you
Rem don't use
Rem  Public Excel As Excel.Application in the Declarations


End Sub

Private Sub Sheet1_GotFocus()

End Sub


Download this snippet    Add to My Saved Code

From Vb to Excel, some simple manipulations Comments

No comments have been posted about From Vb to Excel, some simple manipulations. Why not be the first to post a comment about From Vb to Excel, some simple manipulations.

Post your comment

Subject:
Message:
0/1000 characters