Select Last X Used Cells In Column

Oct 30, 2006

I would like to select the last few cells in a column, however the number of rows is not fixed, it changes. This can only select the fifth last cell:

Sheets("ABC").Range( 'A1:A150').End(xlDown).Offset(-5, 0).Select

Ultimately, i want to select the 5 cells from the fifth last to the last:
from this: Sheets("ABC").Range( 'A1:A150').End(xlDown).Offset(-5, 0).Select

to this: Sheets("ABC").Range( 'A1:A150').End(xlDown).Offset(0, 0).Select

If possible, with the cells selected, can i do something similar to this:

Range("B62:B67").Select
Selection.AutoFill Destination:=Range("B62:B114"), Type:=xlFillDefault
Range("B62:B114").Select

The underlined parts is the part which make me headache. How do i solve this?

View 2 Replies


ADVERTISEMENT

Select All Used Cells In Column

Nov 14, 2006

I have found and selected the very last cell in a column (Say column A). What code do I select all the cells from A1 to that last cell?

View 4 Replies View Related

Select Cells Between 2 Blank Cells In A Column

Mar 29, 2013

I have a huge excel file (who doesn't ) and would like to create a macro to select cells between 2 blanc cells in a column. (Then another macro will continue to select all in the table for that specific range and copy-paste to another sheet. But this part is not relevant)

The details

The table will be like below.

So the macro should select between F2:F6. (then another macro will copy F6:A3 and cut-copy this range to another sheet); and when I re-run this macro this time it will copy the range of Model B..

A
B
C
D
E
F

[Code]...

View 2 Replies View Related

VBA Script To Select Cells In A Column

Aug 6, 2014

[Code] .....

The above code works fine when I have information stored in multiple cells (C9, C10, C11, etc.). However, if I only have data stored in C9, my selection is expanded to the last row. I need a way to select all the data up to first empty cell even if the only cell containing data is C9.

View 4 Replies View Related

Select All Cells In A Column Except Blanks

Jan 9, 2014

In cells A71:A140 I have the following formula: =IF(A4"";A4;"").

How can I select only the cells in range A71:A140 where the formula has returned a value (number or text) and not the blank cells? When I try ctrl + shift + down arrow, all cells in the range are selected...

View 2 Replies View Related

Select All The Blank Cells In A Column

Aug 19, 2006

i need a macro that will select all the blank cells in a column.

View 5 Replies View Related

Select Entire Column Except The Merged Cells

May 19, 2014

I've been working on a macro which delivers a daily report. the report is made up of 4 sections (received orders, scheduled orders, pending orders and unusual orders) each section is topped by a title which is a merge of all columns (A through I) the problem I am having is that the first column displays case numbers (to be displayed in text or number formats) and the 7th and 8th columns are dates When I try to have the VBA select the first column to format as a number, it will select all columns due to the merged cells is there a way to format only non-merged cells of a columns

This is the section I currently use for formatting but it doesn't actually work, (everything ends up in a date format)

[Code] .......

View 2 Replies View Related

Highlight (or Select) Cells From Row 1 Through A Numeric Var X In Column A

Jul 2, 2014

How do I select or highlight cells from row 1 through row x (a numeric variable) in column A? I'm eventually hoping to shift those cells in column A (from row 1 to x) to the right by one.

View 1 Replies View Related

Select A Contiguous Range Of Cells In A Column

May 7, 2009

I'm trying to select a contiguous range of cells in a column and then iterate over that. I keep getting error "91", object variable not set. I have:

View 5 Replies View Related

Select Cells Based Value In Adjacent Column

Jan 4, 2008

How would you select cell values from differing rows based on the name in an adjacent column. ie, if it says John, add that data to the source data, if not move on.

View 5 Replies View Related

Select The Visible Cells And Count Down 50 Rows In Column

Oct 14, 2008

I would like to select the visible cells, and then count down 50 rows in column A - is this possible?

View 9 Replies View Related

How To Select An Entire Range Of Non-Contiguous Cells In A Column

Aug 19, 2009

I recently found this code for selecting a whole column of non continuous cells.

ActiveSheet.Range("a1",ActiveSheet.Range("a65536").End(xlUp)).Select
How can I change the "a1" & "a65536" so it can work and be activecell instead?

View 9 Replies View Related

Find Text In Column Then Select Non Blank Cells To Right And Repeat

Jul 13, 2012

I would like to search Column C for an instance of the text "Std. Residual", then cycle through the non blank cells to the right and run some formatting code:

VB:
'this line will be modified so that i cycle through the non blank cells that i have found
For row_cycle = 1 To 7
'not signifcant
If Abs(ActiveCell) < 1.96 Then
Selection.Interior.Color = 255

[Code] .....

I then want to search for the next instance of "Std. Residual" in Column C, do the same again, and so on for the entire Worksheet.

View 3 Replies View Related

Merge Cells: Select A Range Based On Two Variables Which Store The Column Numbers

Jul 19, 2009

I am trying to select a range based on two variables which store the column numbers. what I have is:

View 4 Replies View Related

Select Case Code For Column A Values To Populate Results In Column B In Same Row?

May 28, 2014

I'm trying to write a simple VBA code to loop through values in the range A14:A138 and based on the value (of a possible four values) in any row of that range, populate the adjacent column in the same row with a conditional result. For example if A14 = "Cat", then B14 = "I"; if instead A14 = "Dog", B14 = "II", etc. If there is no value in column A, the result should be blank (i.e. "").

I believe are in coding the destination range since I can get it to work for just one cell in B! Below is my code that is not working...

[Code].....

View 7 Replies View Related

Basis On 1st Column Automatically Select Input For 2nd Column From Another Worksheet

Mar 18, 2014

I have 02 separate excel workbooks
01 = source file
02 = data list

The workbook "source file" contains all the data
The workbook "data list" contains data for work with Drop-down list. And i can easily select my required description by just dropping down the list.

In case, i have new description i add it in the source file and it is updated in the working "data list" sheet.

This applies to Field device column also. But i want to improve the selection criteria by creating such script or formula which could check the input of the description and automatically selects the field device and its relevant signal (output type).

Screen shot is attached : Automatic Selection.jpg‎

View 1 Replies View Related

Macro - Select Last Non Empty Column And Paste Information In Another Column?

Mar 25, 2013

I am trying to find a macro that look for last non empty cell in column A and them paste a formula/comment in all cells of column B.

View 3 Replies View Related

Keyboard Shortcut To Select Column By The Column Letter?

Jul 24, 2014

I know that this could be a stupid question, but was wondering if it could be possible. I would like to select a column by a keyboard shortcut. If I would press a key combination adding the letter of a column as example F, it would select the whole column. I was trying to search for this in google, but no luck.

View 10 Replies View Related

Select Range Of Current Column To Last Column In Sheet

Jan 30, 2012

I'm trying to make the below two column selections into a selected range to clear out formulas/values in the range.

Current code segments:

ActiveCell.EntireColumn.Select
Columns(ActiveSheet.UsedRange.Columns(ActiveSheet.UsedRange.Columns.Count).Column).EntireColumn.Select

Is there a way to combine the two code segments into one selected range?

View 6 Replies View Related

How To Hide Column After Select Other Specific Column

May 27, 2014

In the attachment is a file, which allows me to specific a Column and hide. For Example enter "H" in the InputBox and Submit the Column "H" is hide.

What do i have to change in the code if i want to hide the "H" and the Column two columns next to "H". In this case "J".

HideColumn.xlsm

View 3 Replies View Related

Lookup In Column A - Select Column B Range?

Feb 11, 2013

I have a sheet that begining in A3 and going down need to look for the First Instance of the text String "Loan Documents" and down to the last instance and select the corresponding range in column B.

Example: if the Text String appears in Range(A14:A32) I need the Range(B14:B32) to be my selected range.

View 1 Replies View Related

How Do You Select A Range Of Cells On Another Worksheet Using The Cells Property

Apr 19, 2007

I seem to be going round and round in circles with this, but I'm sure it should be easy.

I'm just trying to select a range of cells in Sheet2 of my workbook.
I've tried many different bits of code, including:

Dim namesTotal As Integer

namesTotal = 2500

Sheets("Sheet2").Activate
ActiveSheet.Range(Cells(1, 1), Cells(namesTotal, 8)).Select

(According to the Microsoft website, this is supposed to be the way to do it?)

View 10 Replies View Related

Select Column A And B But Not Row 1

Jul 2, 2009

i am trying to select column A and column B and apply a filter. however, I don't want the filter to be applied to row 1...

View 2 Replies View Related

Select LESS THAN Column

Sep 5, 2009

I am trying to select a reference cell value from a column that is LESS THAN.

1. My reference cell value is 22.

2. I look at first row and since 22 < 30, I want to pick values in column 3 (30)

3. Question, how would I get the output below my reference output 22, like i have below?

View 2 Replies View Related

Select Row And Column

Jul 21, 2008

I want the entire row and column of the active cell to be selected - now only column "A:A" gets selected.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveCell.EntireRow.Select
ActiveCell.EntireColumn.Select
End Sub

View 9 Replies View Related

Select Every Other Column In Vba

Mar 1, 2010

how can I just select every other (nth) column based on a selection?

So say I have data in columns A-G. I want to select the data block from A1-G100 and then run this macro so that it keeps just every other (or nth) column selected. So the process would be to highlight the data block, then run the macro and I would be left with the data block every other (nth) column selected so I could format all those cells the same way (column width adjustment so I can't use conditional formatting with =mod(),2).

To take it to another slightly more complicated step- I'd like to ultimately include a box that pops up and asks for how many columns I'd like in between.

So that I could select a data block, then hit a button for the macro, type in a 3 to indicate I want to select every 3rd column and then hit go, and then be left with excel having every 3rd column selected.

View 9 Replies View Related

Highlight Repeat Cells In One Column If Cells In The Adjacent Column Contain Specific Text?

Apr 14, 2014

I am trying to find a solution for highlighting cells in a column that are repeats, ie. >3. I also need these cells to only be highlighted if the adjacent cell in the next column contains specific text. I have tried using conditional formatting with a countifs formula to no avail.

View 2 Replies View Related

How To Select Date Column

Aug 15, 2014

I am using EXCEL VBA and SQL statement to try to select some data in worksheet

Below is my worksheet sample

datee name product_name product_code
2014/6/1 Eric Toy_A C0001
2014/6/3 Stephen Toy_B C0003
2014/6/16 Calvin Toy_C C0003
2014/6/19 Perry Toy_D C0001
2014/6/23 Calvin Toy_E C0002

Here is my code segment for select data

strQuery = "SELECT * FROM[List$] where promoter_name = 'Calvin' and promoter_code = 'C0003'"
Set rs = cn.Execute(strQuery)

This is success to select data with no error

============================
But when I changed the condition to use datee column

strQuery = "SELECT * FROM[List$] where promoter_name = 'Calvin' and datee = '2014/6/23'"

It cannot work The error message said data type incorrect

Do I need to set any thing before run the sql?

View 5 Replies View Related

Select The Cell Same Row Next Column

Jan 29, 2013

The first code is on the top of the module.

Code:
Private Const OPEN_TIME_COL = 3
Private Const CLOSE_TIME_COL = 4

Code:
RowNum = .Cells(.Rows.Count, CLOSE_TIME_COL).End(xlUp).Row + 1
.Cells(RowNum, CLOSE_TIME_COL).Value = Now

So according to the second code, it records the closing time(now), in the CLOSE_TIME_COL(Which is D)
in the next availabe cell, from the CLOSE_TIME_COL....

But here is the part i am trying to change

Code:
RowNum = .Cells(.Rows.Count, CLOSE_TIME_COL).End(xlUp).Row + 1

So that, what it should do is find the last cell used in column C, (OPEN_TIME_COL) and shift right.

if the last cell used in C is C1, CLOSE_TIME.Value should be in D1

for example somthing like this... but this code doesnt work

Code:
RowNum = .Cells(.Rows.Count, OPEN_TIME_COL).End(xlUp).column + 1

View 2 Replies View Related

Select Intersection Of Column And Row

Sep 11, 2008

First although it returns the correct column, it always returns Row 1. Beyond me! Secondly I could really use some help in a line or two of code to select the cell at the intersection of the column and row.

Sub test()

Dim name As String
Dim number As String
Dim col As Integer
Dim row As Integer
Dim RowNumber As Integer
Dim ColNumber As Integer
Dim rng As Range

ActiveWorkbook.Sheets("Sheet1").Activate

name = InputBox("type a name from Column A")...........

View 9 Replies View Related







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