473,498 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

urgent: formatting XL cells

hi. im exporting data from a vb form to excel. i am able to create a new
excel file, save and edit it without any trouble, but the formatting is
giving me hell! i need to be able to show certain cells in bold, with
underlining etc. i dont understand how, but in the following code, the
instruction for bold gets picked up for all the cells (even when i specify
font.bold = false), and the underlining is haphazardly used. the font colour
formatting is also not getting picked up...
can someone please tell me how this thing works and what i should do?
With xlsheet
.Range("B1", "I50").RowHeight = 15
.Range("a1", "i50").ColumnWidth = 8.43

'title of sheet
.Cells(1, 1).Font.ColorIndex = 32
.Cells(1, 1).Style.font.size = 14
.Cells(1, 1).Font.Name = "Arial Black"
.Cells(1, 1).Value = "CONSUL"

'ISO form code
.Cells(2, 7).Font.ColorIndex = 1
.Cells(2, 7).Style.font.size = 10
MsgBox("ISO CODE")
.Cells(2, 7).Style.font.bold = True
.Cells(2, 7).style.font.underline = False
.Cells(2, 7).Font.Name = "Batang"
.Cells(2, 7).Value = "CRF - 02"

'branch
.Cells(2, 1).Style.font.name = "batang"
.Cells(2, 1).style.font.underline = False
MsgBox("branch underline")
.Cells(2, 1).style.font.bold = True
MsgBox("branch bold")
.Cells(2, 1).Style.font.size = 11
.Cells(2, 1).Value = ds.Tables("form1").Rows(ctr).Item("branch")

' form title
.Cells(3, 3).Style.font.underline = True
.Cells(3, 3).Style.font.size = 11
.Cells(3, 3).Value = "CONTRACT REVIEW CUM BDI FORM"

'se code
.Cells(6, 7).Style.font.size = 9
.Cells(6, 7).Style.font.bold = True
.Cells(6, 7).Value = "SE Code"
.Cells(6, 8).Style.font.size = 11
.Cells(6, 8).Value = ds.Tables("form1").Rows(ctr).Item("sec")

'equipment type
.Cells(6, 2).Style.font.size = 11
.Cells(6, 2).Font.ColorIndex = 15
.Cells(6, 2).Font.Name = "Arial black"
.Cells(6, 2).Value = equip
.Cells(6, 1).Value = "Equip"

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200604/1
Apr 17 '06 #1
5 3026
If you have Excel and want to know how something is done, then Open Excel,
create a new worksheet, go Tools > Macro > Record new macro. Record it in
the workbook so you can just get rid of it when done testing. Now what ever
you want to know, just do that manually such as selecting a cell and setting
it's font to bold, etc. When done, stop the recording and open the Visual
Basic Editor under that same menu and open the procedure that was just
created by the macro recording and see how it's being done.

"mrid via DotNetMonster.com" <u16975@uwe> wrote in message
news:5ee7a69c9c6e9@uwe...
hi. im exporting data from a vb form to excel. i am able to create a new
excel file, save and edit it without any trouble, but the formatting is
giving me hell! i need to be able to show certain cells in bold, with
underlining etc. i dont understand how, but in the following code, the
instruction for bold gets picked up for all the cells (even when i specify
font.bold = false), and the underlining is haphazardly used. the font
colour
formatting is also not getting picked up...
can someone please tell me how this thing works and what i should do?
With xlsheet
.Range("B1", "I50").RowHeight = 15
.Range("a1", "i50").ColumnWidth = 8.43

'title of sheet
.Cells(1, 1).Font.ColorIndex = 32
.Cells(1, 1).Style.font.size = 14
.Cells(1, 1).Font.Name = "Arial Black"
.Cells(1, 1).Value = "CONSUL"

'ISO form code
.Cells(2, 7).Font.ColorIndex = 1
.Cells(2, 7).Style.font.size = 10
MsgBox("ISO CODE")
.Cells(2, 7).Style.font.bold = True
.Cells(2, 7).style.font.underline = False
.Cells(2, 7).Font.Name = "Batang"
.Cells(2, 7).Value = "CRF - 02"

'branch
.Cells(2, 1).Style.font.name = "batang"
.Cells(2, 1).style.font.underline = False
MsgBox("branch underline")
.Cells(2, 1).style.font.bold = True
MsgBox("branch bold")
.Cells(2, 1).Style.font.size = 11
.Cells(2, 1).Value =
ds.Tables("form1").Rows(ctr).Item("branch")

' form title
.Cells(3, 3).Style.font.underline = True
.Cells(3, 3).Style.font.size = 11
.Cells(3, 3).Value = "CONTRACT REVIEW CUM BDI FORM"

'se code
.Cells(6, 7).Style.font.size = 9
.Cells(6, 7).Style.font.bold = True
.Cells(6, 7).Value = "SE Code"
.Cells(6, 8).Style.font.size = 11
.Cells(6, 8).Value = ds.Tables("form1").Rows(ctr).Item("sec")

'equipment type
.Cells(6, 2).Style.font.size = 11
.Cells(6, 2).Font.ColorIndex = 15
.Cells(6, 2).Font.Name = "Arial black"
.Cells(6, 2).Value = equip
.Cells(6, 1).Value = "Equip"

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200604/1

Apr 18 '06 #2
hi.

thanks for replying. i tried what you suggested, but am encountering a build
error when i try to use the macros code. eg. i get a
"system.data.range" is not accessible in this context because it is "private".
not very sure what that means! also, for some reason the border setting seems
to throw an error everytime! - even the macros code when pasted in the vb pgm
gets squiggly green lines.

could you please tell me if theres any other way to format those cells?
getting totally frustrated!
+Vice wrote:
If you have Excel and want to know how something is done, then Open Excel,
create a new worksheet, go Tools > Macro > Record new macro. Record it in
the workbook so you can just get rid of it when done testing. Now what ever
you want to know, just do that manually such as selecting a cell and setting
it's font to bold, etc. When done, stop the recording and open the Visual
Basic Editor under that same menu and open the procedure that was just
created by the macro recording and see how it's being done.


--
it's all latin & geek to me! ;-)

Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200604/1
Apr 18 '06 #3
Hello, mrid,

I think that your problem is that you are changing the properties of the
"Style" that is applied to the cells. This will change the attribute
for all cells to which that style has been applied. (Unless you have
done something to change it outside of the code snippit shown, this is
probably the "Normal" style that you are changing, so it will affect all
cells.)

Just remove the ".Style" property everywhere in your code snippit, and I
think you will get what you want.

Cheers,
Randy
mrid via DotNetMonster.com wrote:
hi. im exporting data from a vb form to excel. i am able to create a new
excel file, save and edit it without any trouble, but the formatting is
giving me hell! i need to be able to show certain cells in bold, with
underlining etc. i dont understand how, but in the following code, the
instruction for bold gets picked up for all the cells (even when i specify
font.bold = false), and the underlining is haphazardly used. the font colour
formatting is also not getting picked up...
can someone please tell me how this thing works and what i should do?
With xlsheet
.Range("B1", "I50").RowHeight = 15
.Range("a1", "i50").ColumnWidth = 8.43

'title of sheet
.Cells(1, 1).Font.ColorIndex = 32
.Cells(1, 1).Style.font.size = 14
.Cells(1, 1).Font.Name = "Arial Black"
.Cells(1, 1).Value = "CONSUL"

'ISO form code
.Cells(2, 7).Font.ColorIndex = 1
.Cells(2, 7).Style.font.size = 10
MsgBox("ISO CODE")
.Cells(2, 7).Style.font.bold = True
.Cells(2, 7).style.font.underline = False
.Cells(2, 7).Font.Name = "Batang"
.Cells(2, 7).Value = "CRF - 02"

'branch
.Cells(2, 1).Style.font.name = "batang"
.Cells(2, 1).style.font.underline = False
MsgBox("branch underline")
.Cells(2, 1).style.font.bold = True
MsgBox("branch bold")
.Cells(2, 1).Style.font.size = 11
.Cells(2, 1).Value = ds.Tables("form1").Rows(ctr).Item("branch")

' form title
.Cells(3, 3).Style.font.underline = True
.Cells(3, 3).Style.font.size = 11
.Cells(3, 3).Value = "CONTRACT REVIEW CUM BDI FORM"

'se code
.Cells(6, 7).Style.font.size = 9
.Cells(6, 7).Style.font.bold = True
.Cells(6, 7).Value = "SE Code"
.Cells(6, 8).Style.font.size = 11
.Cells(6, 8).Value = ds.Tables("form1").Rows(ctr).Item("sec")

'equipment type
.Cells(6, 2).Style.font.size = 11
.Cells(6, 2).Font.ColorIndex = 15
.Cells(6, 2).Font.Name = "Arial black"
.Cells(6, 2).Value = equip
.Cells(6, 1).Value = "Equip"

Apr 18 '06 #4
Give us some samples of the macros code you've created.

"latin & geek via DotNetMonster.com" <u16975@uwe> wrote in message
news:5ef2886ff9713@uwe...
hi.

thanks for replying. i tried what you suggested, but am encountering a
build
error when i try to use the macros code. eg. i get a
"system.data.range" is not accessible in this context because it is
"private".
not very sure what that means! also, for some reason the border setting
seems
to throw an error everytime! - even the macros code when pasted in the vb
pgm
gets squiggly green lines.

could you please tell me if theres any other way to format those cells?
getting totally frustrated!
+Vice wrote:
If you have Excel and want to know how something is done, then Open Excel,
create a new worksheet, go Tools > Macro > Record new macro. Record it in
the workbook so you can just get rid of it when done testing. Now what
ever
you want to know, just do that manually such as selecting a cell and
setting
it's font to bold, etc. When done, stop the recording and open the Visual
Basic Editor under that same menu and open the procedure that was just
created by the macro recording and see how it's being done.


--
it's all latin & geek to me! ;-)

Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200604/1

Apr 19 '06 #5
Vice: thank you for responding, problem resolved now.
Randy you were absolutely right! Thanks a million - that was a life saver! :)
R. MacDonald wrote:
Hello, mrid,

I think that your problem is that you are changing the properties of the
"Style" that is applied to the cells. This will change the attribute
for all cells to which that style has been applied. (Unless you have
done something to change it outside of the code snippit shown, this is
probably the "Normal" style that you are changing, so it will affect all
cells.)

Just remove the ".Style" property everywhere in your code snippit, and I
think you will get what you want.

Cheers,
Randy
hi. im exporting data from a vb form to excel. i am able to create a new
excel file, save and edit it without any trouble, but the formatting is

[quoted text clipped - 51 lines]
.Cells(6, 2).Value = equip
.Cells(6, 1).Value = "Equip"


--
it's all latin & geek to me! ;-)

Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200604/1
Apr 19 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2922
by: ImraneA | last post by:
Hi there Have a database, where front-end interface allows user to select a ms access database. From there, standard tables are linked. Routine, that creates a spreadsheet, for each table a...
3
6206
by: washoetech | last post by:
I have a gridview control. In this grid view there is a column for the price of an item. Some of the prices have a dollar sign in front of it and some dont. How do I get rid of the dollar sign...
10
3135
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim...
1
4559
by: euan | last post by:
HI Guys, I have bee using conditional formatting in the datagrid recently and I am moving over to framework 2.0 and noticed the datagrid has been replaced by the gridview. So, I would like to do...
2
7303
by: jacqueharper | last post by:
I need to change the formatting of individual cells in a datagrid. I cannot figure out how to address individual cells by their column name. I have a DataTable which contains (for instance)...
13
2519
by: Niyazi | last post by:
Hi I have a report that I have to run it monthly in my machine. My code in VB.NET and I access AS400 to get data, anaysie it and send into pre formated Excel sheet. The data consist of 9000...
4
8311
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the...
1
1730
by: nickb34 | last post by:
I don't have much experience with VB and I have found Excel's conditional formatting very limited. I need a macro that will search through all the cells and when it finds a blank cell, it needs to be...
10
9642
by: afromanam | last post by:
Regards, Please help What I'm trying to do is this: (and I can't use reports since I must export to Excel) I export some queries to different tabs in an excel workbook I then loop through...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.