change row colors in excel
okay so i have this 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
oexcel = Nothing
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.
By Lennie in forum VB Classic
Last Post: 08-17-2008, 02:24 AM
By OwenDavies in forum VB Classic
Last Post: 03-09-2006, 08:40 PM
Last Post: 07-01-2005, 12:03 PM
By Alexander Frolov [Afalina Co., Ltd.] in forum vb.announcements
Last Post: 06-24-2002, 12:13 PM
By Jon Cohen in forum authorevents.vaughn
Last Post: 05-31-2000, 12:43 AM
Tags for this Thread
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center