-
change row colors in excel
okay so i have this code
<code>
Dim oexcel As Microsoft.Office.Interop.Excel.Application
Dim obook As Microsoft.Office.Interop.Excel.Workbook
Dim osheet As Microsoft.Office.Interop.Excel.Worksheet
oexcel = New Microsoft.Office.Interop.Excel.Application
obook = oexcel.Workbooks.Open("c:\test\test.xls")
osheet = obook.Worksheets(1)
Dim LastRow As Integer = osheet.UsedRange.Rows.Count
osheet.Range("A" & LastRow.ToString + 1).Value = Date.Now
osheet.Range("B" & LastRow.ToString + 1).Value = TextBox1.Text
obook.Save()
obook.Close()
oexcel.Quit()
oexcel = Nothing
</code>
this code basically writes rows to an excel sheet not overwriting any row but systematically enters new lines every time the button is pressed. each row has a column for type of visit i.e. appointment, new, rush
what i want to do is fill the rows with different colors for example if column "B" on whatever row says appointment i want the whole row to be red. ive never had to program the color of an excel row and could use some help! thanks in advance!!
-
The best way to learn how to do something when working with Excel is to have Excel record a macro that does the operation.
You can do that by calling Tools...Macro...Record New macro.
You perform the operation, setting the color of a row in your case.
You click the Stop Recording Button in the small toolbar that was created when you started the recording. If the toolbar is not visible, you can stop the recording through Tools...Macro.
You then Switch to the VBA editor with Alt-F11. In the VBAProject window in the upper left, you should find a module that contains the recorded macro. The Object.Method necessary to perform the operations you did while recording will be there in plain sight. You only have to adjust them to the variables you used in your .NET code.
Jacques Bourgeois
JBFI
http://www3.sympatico.ca/jbfi/homeus.htm
Similar Threads
-
By Lennie in forum VB Classic
Replies: 1
Last Post: 08-17-2008, 02:24 AM
-
By OwenDavies in forum VB Classic
Replies: 0
Last Post: 03-09-2006, 09:40 PM
-
Replies: 2
Last Post: 07-01-2005, 12:03 PM
-
By Alexander Frolov [Afalina Co., Ltd.] in forum vb.announcements
Replies: 0
Last Post: 06-24-2002, 12:13 PM
-
By Jon Cohen in forum authorevents.vaughn
Replies: 1
Last Post: 05-31-2000, 12:43 AM
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|