Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-19-2019, 09:29 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Split selected columns, or all columns exept for Column1 Windows 10 Split selected columns, or all columns exept for Column1 Office 2013
Competent Performer
Split selected columns, or all columns exept for Column1
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Question Split selected columns, or all columns exept for Column1

Hello,
I've been researching how to select a few table Columns to split, but would need to skip the first column to 1 table. Either to select the columns to affect with the macro or to take table(1) but skip the first column.

On certain tables, the first column should be skiped, but the next 2+ columns, needs to be splited in two.

As of Col 2+2, column width :
Selection.Columns.PreferredWidth = InchesToPoints(0.8)
.RightIndent = InchesToPoints(0.08)

As of Col 3+2, column width :
Selection.Columns.PreferredWidth = InchesToPoints(0.13)
.RightIndent = InchesToPoints(0.08)

Any idea? This is what I came up with so far, with the help of Greg for most part.

Sub test_Split_and_Align_1_tbl()
'Got it to work for 1 table
'works but must find way to skip Column(1)
Application.ScreenUpdating = False
Dim oTbl As Table
Dim lngRow As Long, lngCol As Long
Set oTbl = Selection.Tables(1)
With oTbl.Range.Find
oTbl.Range.Select
Selection.Cells.Split 1, 2, False
For lngCol = 3 To oTbl.Columns.Count Step 2
oTbl.Columns(lngCol).Width = 48
Next lngCol
For lngCol = 4 To oTbl.Columns.Count Step 2
oTbl.Columns(lngCol).Width = 12
Next lngCol
For lngRow = 1 To oTbl.Rows.Count
For lngCol = 3 To oTbl.Columns.Count
If lngCol Mod 2 = 1 Then 'an odd column
oTbl.Cell(lngRow, lngCol).Range.ParagraphFormat.Alignment = wdAlignParagraphRight
Else


oTbl.Cell(lngRow, lngCol).Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
End If
Next lngCol
Next lngRow
End With
'Next
lbl_Exit:
Exit Sub

End Sub

Last edited by Cendrinne; 09-19-2019 at 09:31 PM. Reason: removed extra space
Reply With Quote
 

Tags
skip columns, split, table



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert 8 columns into 3 columns BendixB Excel Programming 2 08-08-2018 12:39 PM
Adding selected entries in columns in Excel hillbilly Excel 4 07-16-2015 01:07 AM
Split one column to several columns moishy Excel Programming 1 02-01-2013 12:50 AM
Independent, Split Columns in Word? dave0620 Word 3 12-12-2011 07:15 PM
Split selected columns, or all columns exept for Column1 How to compare 2 columns with other two columns in EXECL 2007? Learner7 Excel 5 06-12-2010 09:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft