VB code for Excel cell text to Horizontal Center Alignment
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-01-23 12:21 PM
Hi,
I need VB code for Excel cell text to Horizontal Center Alignment.
Below is the code i am currently using which is not a complete one as some content and dependencies seems to be missing.
------------------------------
Pasupuleti Mounika
Senior RPA Developer
Genpact India LLP
Asia/Kolkata
------------------------------
I need VB code for Excel cell text to Horizontal Center Alignment.
Below is the code i am currently using which is not a complete one as some content and dependencies seems to be missing.
Dim wb, excel, Range As Object
Try
wb = GetWorkbook(Handle, Nothing).ActiveSheet
excel = wb.Application
Range = excel.Selection
Range.HorizontalAlignment = xlCenter
Finally
wb = Nothing
excel = Nothing
Range = Nothing
End Try
Kindly need your help in this.
------------------------------
Pasupuleti Mounika
Senior RPA Developer
Genpact India LLP
Asia/Kolkata
------------------------------
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-01-23 09:11 PM
Hi
I think you are almost there with your code but since this is vb you will likely need to change the xlcenter to enumeration instead. The below link will give you a list of alignments which should hopefully help you out with this.
https://learn.microsoft.com/en-us/office/vba/api/excel.xlhalign
------------------------------
Michael ONeil
Technical Lead developer
NTTData
Europe/London
------------------------------
I think you are almost there with your code but since this is vb you will likely need to change the xlcenter to enumeration instead. The below link will give you a list of alignments which should hopefully help you out with this.
https://learn.microsoft.com/en-us/office/vba/api/excel.xlhalign
------------------------------
Michael ONeil
Technical Lead developer
NTTData
Europe/London
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-01-23 01:53 PM
Thank you Michael for quick response. It worked.
------------------------------
Pasupuleti Mounika
Senior RPA Developer
Genpact India LLP
Asia/Kolkata
------------------------------
------------------------------
Pasupuleti Mounika
Senior RPA Developer
Genpact India LLP
Asia/Kolkata
------------------------------