|
#1
|
||||
|
||||
Help to get Table Cells Selection as a Range
Hello Pros,
I've been searching for 5 hours, and still can't find a solution, so I need Pro Help! I have a great macro where I tell which 2 sets of cells/columns to select as a range. It does a fantastic job, then I use a Find and Replace macro to make a number of changes, and it doesn't touch other columns in the same table or other columns in the previous tables or forward tables. It doesn't even touch paragraphes The only 2 thing, is that is it block at tables(1) and I wish to have InputBox for variable set of cells. I've tried to put xText# but now it gives me error message and I can't figure out why. The other macro, gives me the table index number. I'm trying to incorporate it togerther. Can't figure out how. Here are the two macros: Macro#1 Get table index number: Code:
Sub Find_Table_Index_number() MsgBox ActiveDocument.range(0, Selection.Tables(1).range.End).Tables.Count End Sub Code:
Sub TEST2_TBL_FR1_Selection_of_cell() 'To select a range of cells within a table, declare a Range variable, assign to it the cells you want to select, and then select the range 'Cell(1= first row /, 1 = 1st Column ----to Range End, Cell (11 = 11th Row /, 5 = 5th Column) Dim oTbl As Table Dim myCells As range Dim sText1 As Integer 'Table Index Range Number to Select Dim sText2 As Integer 'Table First Row to Start the Table Range Selection Dim sText3 As Integer 'Table First Column to End the Table Range Selection Dim sText4 As Integer 'Table Last Column to End the Table Range Selection Set oTbl = Selection.Tables(1) With ActiveDocument sText1 = InputBox("Enter the desired Table Number to Select") sText2 = InputBox("Enter the desired Table First Row to Start the Table Selection") sText3 = InputBox("Enter the desired Table First Column to Start the Table Selection") sText4 = InputBox("Enter the desired Table Last Column to End the Table Selection") 'Set myCells = .range(Start:=.Tables(1).Cell(1, 2).range.Start, _ End:=.Tables(1).Cell(99, 3).range.End) Set myCells = .range(Start:=.Tables("sText1").Cell("sText2", "sText3").range.Start, _ End:=.Tables(1).Cell(99, "sText4").range.End) myCells.Select End With Set myCells = Nothing: Set oTbl = Nothing On Error GoTo 0 End Sub Thanks in advance, pro's. Cendrinne |
Tags |
selections, table cell range |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Copy range of cells from excel to either bookmarks or to insert in table in word | hinchi1 | Excel Programming | 6 | 04-27-2020 01:55 PM |
Edit table cells based on content control selection | gennatr12 | Word VBA | 7 | 03-26-2017 08:51 PM |
Distribute text in one cell across a range of cells (overcoming selection.range.cells.count bug) | slaycock | Word VBA | 0 | 02-18-2017 07:00 AM |
Selection (range) in Word or Excel table | NobodysPerfect | Word VBA | 2 | 09-16-2014 12:06 AM |
Set range for merged Word table cells? | tinfanide | Word VBA | 1 | 02-06-2012 05:57 AM |