VBA To Add / Remove Border Around Merged Cells
Oct 5, 2012
I've got some VBA that adds and removes a border around a merged cell. I created it by recording a macro and it's pretty clunky. It needs to do this for 6 different merged cells, based on different events and takes around 5 seconds to complete. Not a major problem, but I was hoping that I could make it more efficient. Anyway, code below:
Adding the border:
Code:
Sub AddRAGBorderChart1()
'
' AddRAGBorderChart1 Macro
'
'
Range("D4:M15").Select
[code]....
Removing the border:
Code:
Sub RemoveRAGBorderChart1()
'
' RemoveRAGBorderChart1 Macro
'
'
Range("D4:M15").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
[code]....
View 6 Replies
ADVERTISEMENT
Aug 13, 2012
I have a picture that has been inserted into a worksheet via a macro and I have a number of macros to increase and decrease size. They work fine.
However, whenever I run one of those macros by selecting a button on the worksheet, it results in a border around the picture.
Facts:
- worksheet is called "Admin"
- picture is called "ClientLogo"
- Line.Weight set to "0" or "False" or "xlNone" or removed all result in a border
Question: Code / syntax for removing or setting the border to nothing?
VB:
Sub ReduceShape()
Dim shp As ShapeRange
On Error Goto NoSelectionMade
Sheets("Admin").Shapes("ClientLogo").Select
Set shp = Selection.ShapeRange
[Code]...
View 2 Replies
View Related
Jul 28, 2006
The border around a user form is really annoying. Is there any way to remove this so that when you load the user form without a title bar your image you use is just your image and not with a border around it???
View 4 Replies
View Related
Sep 4, 2009
After using Copy/Pastespecial in my macro, when it completes I have the flashing border around the range that was copied, (like you do when you do it manually).
What line of code do I need in my macro to make this go away?
View 3 Replies
View Related
Dec 11, 2009
Im creating a form with a spin box option - however when i run it in test I always get a black border around the arrows. Its anoying because I want to make the spinbox small and it overtakes the arrows. I looked everywhere in the properties but can't find where to turn it off. I saw the arrorw and background color but nothing about the border.
I attached 2 pictures for reference.
View 9 Replies
View Related
May 29, 2014
I wish to copy a merged cell (3 cells) based on if only 1 of 3 cells to the right contain "X". if the top cell does not contain "X" than the merged cell is not copied. Also, is therea more elegant to copy 3 columns at a time rather than do one at a time as my code shows:
Sub CopyICUCAPU()
'
' CopyICUCAPU Macro
'
Dim i As Integer
[Code].....
View 14 Replies
View Related
Mar 23, 2006
Below a small example with the borders as they should be. How do i get a macro to put the borders automatically, depending on the similarity of the cells in column B ? Note the blanc column with the borders should be made automatically as well. Second problem: the minimum height of a "border" should be 34pixels as in the example so you can write something in there after printing the sheet.
View 9 Replies
View Related
Jul 19, 2012
I need to underline certain cells based on the value of a cell in this case from column "E". Right now I run a macro to look at the value in each cell in column "E". THe macro then adds a certain amount of blank rows below the that row. So, if cell E1 has a 4, my macro runs a calculation that says 4 divided by 3, +2. So it would add 3 blank rows under row 1. It does this all the way down my column of data.
Now it gets tricky. To the right of column E, I have 6 blank columns, F,G,H,I,J,K. F,H, and J are spacer rows with no data. I need them blank with out any borders. Columns G, I, and K are the columns that I am wanting to add borders on the bottom of the cells based on the value in column E.
I need code to look at the value in E1, in this case 4, and add borders to 4 cells, in this case G1, I1, and K1 and then G2. If the value would have been 5, I need I2, 6 would add a border to K2 and 7 would add a border to G3. Catch my drift?
So, every cell in column E will not have a value because of me adding blank rows. So when there is a value, I need to add borders starting on the same row the value is in. At most, there will only be 3 underlined cells per row because of the format. Once the top row is filled, I need to drop down to the very next row.
View 9 Replies
View Related
Aug 3, 2008
I am trying to have a border drawn around a group of cells. This group of cells changes per list I make, but only the height changes. The width is always the same (from column A to column J) and the top is always at row 5. Only the last row changes. How can a border be drawn around this group of cells no matter the size of the group of cells? Below is the macro I have written so far.
Cells.Select
Cells.EntireColumn.AutoFit
ActiveWindow.SmallScroll ToRight:=7
Columns("K:N").Select
Selection.ClearContents
ActiveWindow.SmallScroll ToRight:=-7
Range("A2").Select
Rows("2:2").RowHeight = 49.5
lastrow1 = Range("A65536").End(xlUp).Select
Range("A5:J" & lastrow1).BorderAround.Weight = xlThin
lastrow2 = Cells(Cells.Rows.Count, "C").End(xlUp).Row
For I = lastrow2 To 2 Step -1..........................
View 2 Replies
View Related
May 28, 2009
I am looking for a code that will clear all of my unlocked cell in sheet 1. That is not a problem but since many of the cells are merged I know it keeps throwing me an error saying cannot change contents of merged cells or something like that. Does anyone know how to get around this without unmerging the cells. I saw a code to unmerge all of the cells on a sheet but I really don't want to do this as I already have worked around most of my problems with the merged cells.
View 14 Replies
View Related
Nov 7, 2005
I have an extensive spreadsheet with several columns and all showing borders where each cell/column begins and ends. However there are a few cells where the break with the next cell does not show the line.
I have highlighed the cell in question, gone to format/cell/borders and everything looks fine. Black color + format border shows square with all sides of square showing.
View 3 Replies
View Related
Mar 2, 2012
I recorded this and I was wondering if there was a more simple way to add a thin style border to my cells?
'Insert BorderUnion(Range("K6", Cells(LastRow, "K")),
Range("B6", Cells(LastRow, "B"))).Select   Â
Selection.Borders(xlDiagonalDown).LineStyle = xlNone   Â
Selection.Borders(xlDiagonalUp).LineStyle = xlNone   Â
[Code] ......
View 3 Replies
View Related
Feb 28, 2007
Using VBA how could I put a border around any cell that isn't empty within the range B1:C500. (Worksheet name - Floc BOM)
View 9 Replies
View Related
Nov 3, 2008
I am trying to Put a border around cells that arent empty. Is this possible?
View 11 Replies
View Related
Nov 20, 2013
I'm writing/recording a macro and would like some VBA code. I'm trying to make a border around all used cells in my sheet. When I use the macro there will be a variable number of used cells.
I'd like code that says:
If cell A2 has text then format cells A2:CL2 with an outline border Repeat for each row in the sheet until there there is no more text in column A.
Also, not sure if it matters, but I'm working on a mac.
View 9 Replies
View Related
Nov 13, 2008
I have a spradsheet that I've formatted using merged cells. The spreadsheet has several columns. Into these columns I must enter raw data extracted from our SAP data base. The extraction worksheet has no merged cells. So bottom line, I have a column of say, 30 non-merged cells and I want to paste that column into my formatted spreadsheet that has 30 merged cells of thre cells a piece (90 cells total).
So far I have been unable to do this. If I've attached it correctly, the sample attached
MERGE EXAMPLE.xls‎
View 7 Replies
View Related
Oct 21, 2013
Im having problems trying to sort through data and linking certain data. I will post example below:
Main 1
Main 2
Main
3
Sublevel 1-4
[Code]....
This is just one part of a row of the workbook but shows the Main data which is made up of 4 different sub levels on the right. I merged 4 cells for the main data so that all the cells lined up but I'm still having problems with being able to sort and link the files together so that when I filter, they all do it together. The example didn't paste well.
View 3 Replies
View Related
Oct 23, 2008
I'm trying to double-click a cell to edit the contents, and I am off a few pixels, it treats the double-click as a double-click on the cell border, not the cell contents, and the focus jumps to another cell in the direction of the border instead of going into edit mode. The effect is as if I had pressed Ctrl and the arrow in the direction of the border I clicked on.
The only way I've found to disable this is to turn off the option "Enable fill handle and cell drag-and-drop", but unchecking that also disables actually useful things, like dragging the corner of a formula call to copy it down, etc.
Is there a good way to disable this cell jumping when I accidentally double-click a cell border?
View 9 Replies
View Related
Feb 22, 2010
i have a problem to sort merged cells in the file attached. i tried via macro but could not reached a good solution. I have 30 plans inside the sheet and even manually is too hard to do it because i use some "=" to not type again every number since some are the same but when i try to sort the lines became diferent values.
View 10 Replies
View Related
Aug 12, 2009
I now see why alot of you dont like merged cell's. What i am trying to do is Cut and paste a range that contains merged cells. A kit can be created using the Button on the sheet. The cells in column G are merged down to the last kit item. On Row A of the kit the 1st cell contains data validation once the Delete kit cell is re-entered it removes the selected kit from the sheet. Then will select all kits below the (now deleated one) and cut the range, and paste it to where the old kit was located.
When the kit's are pasted into the new location there are issues with the merged cells in column G. Is there a way to fix this issue, or know of another approach to keeping the same layout.
View 5 Replies
View Related
Sep 17, 2007
I have merged cell C2:C9. When I insert formula =C5, it returns 0. How do I make it to return the actual value?
View 11 Replies
View Related
Feb 13, 2012
I have exported a report to Excel from a BI tool called ZAP.
Unfortunately the cells in the columns are merged by group eg. salesperson, product, country.
I need to be able to filter by each of the columns - the only way i can think of is to unmerge and copy the information to the rest of the "merge area".
This will be extremely time consuming as there are more than 1000 rows and at least 5 columns that I want to filter.
Sales PersonCountryCustomer NameProduct Model DetailJohn WUNITED KINGDOMAPCBasicPremiumStandardStAPLAccessoriesAcrylic FsPremiumFsStStyAPOAccessoriesPremiumStandardStAPMFsPremiumStandardSt
View 3 Replies
View Related
Oct 8, 2012
I have a spreadsheet that has merged cells on that is typed into.
I have a Macro that pulls the information into another sheet and then it tries to clear the cells for the next person to fill in. The issue I am having is that i cant clear the merged cell. I have tried the following code
Code:
Sheets("Coach").Select
Cells(18, 2) = ""
Range(Cells(18, 2), Cells(26, 11)).ClearContents
Sheets("Coach").Cells(18, 2).ClearContents
View 5 Replies
View Related
May 15, 2007
I have a table where sometimes cells are merged. To the right they are not merged, but I need to link to the value of the merged cell. How can I do it if I don't want to do it manually?
Example:
Say A1:A4 is merged, A5 is just normal. I want a formula using those values, say in B1:B5. Now just filling down the formula would reference A1, A2 and so forth. This is wrong.
View 9 Replies
View Related
Jan 23, 2010
when i try to link a merged cell to retrieve result, i get cell ref for both cells, i only like to see B7 not B7:E7.
Summary C708 Spreadsheet FormulasCellFormulaC7='Abode Homewares Pty Ltd'!B7:E7 Excel tables to the web >> Excel Jeanie HTML 4
View 9 Replies
View Related
Jul 22, 2009
I have a workbook in Excel 2007 where I am creating a summation worksheet through the use of arrays which sumif and countif the other worksheets. Things went fine until about halfway through when I started getting merged cell errors. In between the calculations, I had some merged cell rows for section titles. I was not entering the array into them, but researched the error and unprotected the cells. Problem solved. Now, with 10 row to go, I started getting the error again. I unmerged the sectional title rows. I verified that the cells are not protected. However, when I ctrl+shift+enter to input the array, my formula is moving from the cell that I am inputting to, to the cell in the row directly beneath it.
View 3 Replies
View Related
Apr 16, 2007
I need to compare cells in two worksheets but with a difference ex:
Worksheet 1 contains merged/single Cells
Worksheet 2 contains single Cells
Now , i fneed to compare first merged/single cell in Worksheet1 with first single cell in Worksheet2 and similarly , second merged/single cell in Worksheet1 will be compared with second single cell in Worksheet2 and so on.........
Though i can use exact and compare them maually by specifying cells but since i need to make it general , suppose second time there can be some other combination of Merged cells I need to compare with Worksheet2 .
View 9 Replies
View Related
May 8, 2007
I have a merged cell area, several columns wide and 2 rows deep.
I know that pressing enter before reaching the end of the first row moves to the next cell below. Is there any method, either key combination or whatever, of moving to the next row within the merged cell?
View 3 Replies
View Related
Aug 20, 2007
I have the following VBA script that merges 2 cells together, but at the end of the merge I need it to add the filename and path of the active workbook.....
Sub Merge()
Dim Cell_e, Cell_Sheet1 As Variant
Dim R, C As Integer
'This Macro is add the Test condtion and the precondtions together in 1 cell, before they are exported to TD
Sheet2.Select
R = 11
C = 9
Do Until Sheet1.Cells(R, 9).Value = ""
Cells(R, 9).Select
Cell_Sheet1 = Sheet1.Cells(R, 9).Value
Cell_e = Sheet2.Cells(R, 7).Value
Sheet2.Cells(R, 7) = "Test Condtion: " & Cell_Sheet1 & Chr(10) & Chr(10) & "Test Preconditions " & Cell_e
R = R + 1
Loop
End Sub
View 3 Replies
View Related
Jun 14, 2008
I have read the posts regarding merged cells and understand they should be avoided, but I am working with spreadsheets created by others. My problem is that I need to sort the data, but some of the cells are merged so it won't work. Is there a macro command to easily find the merged cells and unmerge them?
View 5 Replies
View Related