Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Visual Basic & Excel

Thread Tools
 
Search this Thread
 
Old 18 December 2002, 10:37 AM
  #1  
SinghSuperStud
Scooby Regular
Thread Starter
iTrader: (2)
 
SinghSuperStud's Avatar
 
Join Date: Jul 2001
Location: Walsall
Posts: 1,918
Likes: 0
Received 0 Likes on 0 Posts
Post

Hi !

Any VB experts / users on here ?

Need help on a simple task ! If somebody can help or will do it for me then drop me a line. Reckon it'll take about an hour for experienced vb'er !

Thanks Jai
Old 18 December 2002, 11:07 AM
  #2  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

what are you trying to do?
Old 18 December 2002, 12:26 PM
  #3  
SinghSuperStud
Scooby Regular
Thread Starter
iTrader: (2)
 
SinghSuperStud's Avatar
 
Join Date: Jul 2001
Location: Walsall
Posts: 1,918
Likes: 0
Received 0 Likes on 0 Posts
Post

I'm trying to transfer the contents of a listbox into cells! SOunds simple but I've only just started with visual basic !


I have a drop down listbox and two list boxes. One listing options you add to the secondary box and then confirm. These options should then be input into a specific column based on the value in the drop down combo.

I have the correct code for the listboxes to add and remove options but how do I transfer the contents of the second listbox (listbox2) into the spreadsheet ?

Once these values from listbox2 are carried over I need to select another value from the dropdown combo which resets the contents of listbox2 so I can then select options again, these inturn are then transferred to another column on the spreadsheet.

ANy helpe appreciated !!!

Jai
Old 18 December 2002, 02:44 PM
  #4  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

to get to all the elements in a listbox
for x=0 to list1.listcount-1
debug.print list1.list(x)
next x

to do the excel stuff


Dim objExcel As Excel.Application
Dim objWorksheet As Excel.Worksheet
Const XL_NOTRUNNING As Long = 429
Const Bold As Boolean = True
Const Regular As Boolean = False
Const Wrap As Boolean = True
Const NoWrap As Boolean = True


Sub OpenExcelSheet()
Set objExcel = Excel.Application
objExcel.Visible = False
objExcel.SheetsInNewWorkbook = 1
objExcel.Workbooks.Add
Set objWorksheet = objExcel.Worksheets("Sheet1")
end sub
Sub WriteCell(sText As String, lCol As Long, lRow As Long, sFontName As String, _
iFontSize As Integer, bBold As Boolean, sAlignment As String)

With objWorksheet
If Left(sText, 1) = "'" Then
.Cells(lRow, lCol).Value = sText
Else
.Cells(lRow, lCol).Formula = sText
End If
.Cells(lRow, lCol).Font.Name = sFontName
.Cells(lRow, lCol).Font.Size = iFontSize
.Cells(lRow, lCol).Font.Bold = IIf(bBold, True, False)
.Cells(lRow, lCol).VerticalAlignment = xlTop
.Cells(lRow, lCol).HorizontalAlignment = IIf(LCase(sAlignment) = "left", xlLeft, xlRight)
'.Cells(lRow, lCol).Font.Color = RGB(255,0,0)
End With
End Sub
Sub CloseExcelSheet(ByVal sFileName as string
objWorksheet.SaveAs FileName:=CloseExcelSheet, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
objExcel.Quit
Set objWorksheet = Nothing
Set objExcel = Nothing

End Function


[Edited by Fosters - 12/18/2002 2:47:25 PM]
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Frizzle-Dee
Essex Subaru Owners Club
13
01 December 2015 09:37 AM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
leg200
Subaru Parts
5
07 October 2015 07:31 AM
has-scooby
Subaru Parts
4
06 October 2015 03:47 PM



Quick Reply: Visual Basic & Excel



All times are GMT +1. The time now is 03:58 AM.