Using VBA To Add Border To Bottom Of Certain Cells

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


ADVERTISEMENT

Macro For Conditional Formatting Bottom Border

Jul 9, 2014

Possible to create a macro that would detect end page (jumping from page 1 to page 2 for instance) and add a bottom border at the last row of the page.

I have attached a sample where I highlight in green the end of the page and added manually the bottom border (I did it only for the first end pages).

View 7 Replies View Related

Bottom Border Depending On Matching Cell Value

Jul 25, 2009

I want to add borders to a range depending on the value in the "a" column. Normally I want a left border in cell "a", a right border in cell "h" and bottom border in cells "a" to "h". However if the value in cell "a" is the same as the cell below I do not want the bottom border.

Cell "a" contains the names of customers using our facilities each day. Some customers use several facilities on the same day. I want the borders to encompass all facilities used by each customer per day e.g. range "a1:h8" might need bottom borders on all rows, because they are single customers using only one facility that day but ranges "a9:h11" would require bottom borders only on row 11, because that customer is using three of our facilities that day.

Set Rng = ActiveSheet.Range("a:h").SpecialCells(xlCellTypeConstants)
change the Range to "a:h"
and:-
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)..........

View 5 Replies View Related

Bottom Border And Yellow Pattern In Condition Formatting

Jul 27, 2009

I am now trying this using Conditional Formatting in Excell 2000; so limited to 3 conditions. However I cannot get it work with multiple conditions:-

Values;-

A34 = Heritage Rly Assn Business Development Committee
A35 = North London Rly Historical Society
C34 = 23/09/2009 (formatted as WEEKDAY DD MMM YYYY)
D34 = 23/09/2009 13:30 (formatted as HH:MM)

In Cell C34

Format condition 1:-

=A34<>A35 , Format Bottom Border

Format condition 2:-

=AND(WEEKDAY(C34)>1,WEEKDAY(C34)<7,HOUR(D34)<18,A34<>A35), Format Bottom Border and Yellow pattern

Format condition 3:-

=AND(WEEKDAY(C34)>1,WEEKDAY(C34)<7,HOUR(D34)<18), FormatYellow pattern

In cell c34 Format condition 1 activates NOT condition 2.

In another cell, C13, condition 3 correctly operates; in this row A13 = A14. Condition 1 works i.e. the cells A1 and A2 are the same only cell A2 has the bottom border and if Cell A2 and A3 are different there is a bottom border in both cells. There must be something wrong with my formula in condition 2 but I can't see what; condition 2 is just condition 1 amd 3 amalgamated.

The condition 2 should read:

If the date is not a Saturday or Sunday in cell C34 and the time is before 18:00 hours in Cell D34 and the name in the "a" cell i.e. A34 does not equal the name in the "a" cell below this one i.e. A35 put in a bottom border and colour the cell yellow.

View 2 Replies View Related

Apply A Bottom Page Border In Excel File?

Nov 6, 2012

I want to apply a bottom page border in my excel file. The page border should be fixed, i.e. if you insert a row above the border then the border should not shift as well.

View 2 Replies View Related

VBA - Adding Border Line To Bottom Row Of Set Print Area

Oct 15, 2009

I am using the following macro to set print area which I found on the net. I am trying to modify it as I would also like to place a border line on the bottom row but cant find anything to assist me despite searching through several threads.

Dim myrange As String
With ActiveSheet.Range("A:A")
myrange = .Find(What:="*", After:=.Range("A1"), LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Address
End With
ActiveSheet.PageSetup.PrintArea = "$K$1:" & myrange
End Sub

View 9 Replies View Related

Excel 2010 :: Place Textbox Between X Axis And Bottom Border Of Chart

Oct 27, 2011

In Excel 2010 I need to place a text box between the X axis and the bottom border of a chart.

How can increase the white space between the X axis and the bottom border to allow me to do this?

View 1 Replies View Related

Border Around Cells With Same Value

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

Excel 2003 :: Conditional Format Top / Mid / Bottom 33% Of Cells But Ignoring Blank Cells

Mar 25, 2012

I am trying to conditionally format the top middle and bottom thirds of a range of data. Problem is, that the range needs to be flexible as sometimes there may be a maximum of 36 cells with data, but sometimes there may be less (so there are blank cells in the range that need not be counted). The methods I have tried always include the blank cells, and so it is not equally formatting the thirds (as it includes the blanks cells as part of the bottom data)....

Here are the 2 methods Ive tried so far using excel 2003)
Top 34%:
=IF(INT(COUNT($D$3:$D$38)*34%)>0,LARGE($D$3:$D$38,INT(COUNT($D$3:$D
$38)*34%)),MAX( $D$3:$D$38))0,LARGE($D$3:$D$38,INT(COUNT($D$3:$D
$38)*67%)),MAX( $D$3:$D$38))0,LARGE($D$3:$D$38,INT(COUNT($D$3:$D
$38)*100%)),MAX( $D$3:$D$38))

View 4 Replies View Related

Border Last Range Of Cells

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

Border Lines Are Not Showing For Some Cells?

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

How To Add Thin Style Border To Cells

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

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 View Related

VBA - To Border Cells With Entry In A Given Range

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

VBA - Putting A Border Around Cells That Arent Empty

Nov 3, 2008

I am trying to Put a border around cells that arent empty. Is this possible?

View 11 Replies View Related

VBA Code To Create Border Around Used Cells In Worksheet

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

Double-Click Cell Border Jumps To Other Cells

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

Bordering A Range (draw The Border For The Cells With In The Usedrange From Column A To BM)

Sep 21, 2009

I would like to draw the border for the cells with in the usedrange from column A to BM.

I have the below code, that I was using to border the column D alone.
When i change the range from "A:BM", i dont get the intended output.
Can somebody tell, what modification, I should do to get the desired output?

View 5 Replies View Related

Way To Copy A Series Of Cells From Top To Bottom

Mar 26, 2007

Is there a way to copy a series of cells from top to bottom, then paste them back so the would be bottom to top?

View 9 Replies View Related

Excel 2003 :: VBA Macro - How To Prevent Cell Border Changes To Unprotected Cells

Aug 3, 2012

I have unprotected cells in excel where I need to change the content (number) and cell color, but I don't want the cell borders to change. I'm a beginner with vba. I've tried protect sheet and workbook options, but looks like I need a vba code and don't know where to start.

Win 7
Office 2007

View 4 Replies View Related

Loop Range Of Cells. Top To Bottom, Left To Right

Nov 7, 2006

I have a spreadsheet which is going to be populated everyday from figures from another spreadsheet using autofilters and the very useful SubTotal worksheet function. I'll attach a copy of the work in progress, also there will be a macro in here which Everytime the user presses update, it copies a range of cells and formatting and pastes it to the next available cell on the right. I've also drawn the movement of the cells i'd like The reason being, is that its going to give day to day, up to date figures from a datasheet.

The problem i have is that when i come to populate the grid which has been copied, i need a calculations to populate each cell in the Less<1week column, then when it gets to the bottom, move Back to the top, and accross to the right 1, and then populate down again, and so on until the end of the grid in question, i dont think i can use a for/next loop becuase it will be a different column address everytime. I dont really like loops, but i feel this needs it.

View 6 Replies View Related

Linked Sheets, Sort Cells, Blanks To Bottom ....

Sep 13, 2009

I'm creating an excel sheet that is linked to several others. Basically my salesmen will enter their new prospects into their own sales sheets and that will transfer via a link to my main one. The problem I'm having is mainly with my sort.

When the information is transferred, I need the sheet to auto sort the Company names alphabetically and move any blank cells to the bottom.

View 2 Replies View Related

Keyboard Shortcut To Highlight All Cells In A Column From Bottom To Top

Jul 7, 2009

What is the best way to highlight all cells in a column from bottom to top?

For example, if I'm in column O, row 138, what keyboard shortcut would I need to select ONLY and ALL cells from the row I'm currently on, (in this example, 138) to row 1 and ONLY in that particular column?

Keep in mind that the next time I may be starting at row 1,200, it could be different everytime.

I tried everything I could think of..


CTRL+A
CTRL+SHIFT+A
CTRL+HOME
CTRL+SHIFT+HOME
CTRL+UP ARROW
CTRL+SHIFT+UP ARROW
CTRL+PAGE UP
CTRL+SHIFT+PAGE UP

and nothing worked to select everything in that column from the row I'm currently on, to row 1.

View 9 Replies View Related

Linked Sheets, Sort Cells, Blanks To Bottom

Sep 7, 2009

I'm using links to pull our sales prospects from our salesmen's individual sheets into one master sheet for reference. Once the prospect information arrives in the sheet, I need it to sort alphabetically by customer name so that we can see which customers have been visited and don't visit the same customer twice.

So far in VB, I've been working on this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("A5:L" & Cells(Rows.Count, "L").End(x1Down).Row).Sort Key1:=Range("B6"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

But it's not sorting the way that I need to. All I really need is for the sheet to sort automatically by Company Name and for all of the 0's to go to the bottom. They are 'blank' data that will eventually be imported from the salesmen's individual sheets as they encounter new customers.

View 9 Replies View Related

Sort Blank Cells (Empty Text) To Bottom

Aug 7, 2008

When choosing ascending or decending, is it possible to always keep rows with the designated blank cells at the bottom? Trying to prevent the blank cells from popping on the top when i filter by a certain field.

View 4 Replies View Related

VBA Code To Add A Border

Oct 4, 2011

The below code adds a line to the next blank row. I would like to add a border to this row that the values are going into. Columns "A:G"

Code:

Private Sub CMD_Add_Click()
Dim rNextCl As Range
Set rNextCl = Worksheets("Main").Cells(Rows.Count, 2).End(xlUp).Offset(2, 0)
Worksheets("Main").Activate
rNextCl.Select
Dim iRow As Long

[Code]....

View 9 Replies View Related

VBA To Put Border Around A Range

Mar 15, 2013

I am after a bit of code which find a value in a cell "Grand Total" it may not be a the last row

Then finds the last column in the row and puts a border around the whole range.

View 4 Replies View Related

Border Around Duplicates

Jan 29, 2009

I have a list (approx 2000 rows). I'd like to put a seperate border around any duplicates that are in the fourth column. If there isn't a duplicate then the regular gridlines are fine. I'd only like the first four columns to include this border. Is there a way for excel to automatically place borders around duplicates? Here is an example of what I have and what I would like it to look like.

View 9 Replies View Related

VBA To Know What Kind Of Border It Is

Mar 28, 2009

Does any know of excel code to know what know what kind of border it is. I converted a pdf file and now the data are on excel and there are borders and it looks to me like it is border with thickness of medium but when I run a code I produced and mark X to the column next to it to show that it is that border it gave me X on all the rows and so the medium thick border is excel grid without any borders.

View 9 Replies View Related

Add Border Around Selection

Aug 24, 2007

There was also another bit of code which added a border around the selected text.
It got stuck on this:

With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

The problem was that there was no Inside Horizontal if there was only one row. I had to chage my code to include a header as well as any selected rows - giving me the two row minimum required. This does the job for now - I'll have to give it some thought on how to get around the problem without the extra header though.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved