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
ADVERTISEMENT
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
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
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
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
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
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
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
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
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
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
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
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
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
Feb 19, 2010
As the title sugests I would like to Select a cell and a macro will highlight the row and column
Sub Select_Entire_Row()
Dim RowNo As Integer
Dim ColNo As Integer
RowNo = Selection.Row
ColNo = Selection.Column
If RowNo.Value >= 1 Then
Cells(RowNo, ColNo).EntireRow.Select ' I want it to do both not one then the other
Cells(RowNo, ColNo).EntireColumn.Select
End If
End Sub
View 9 Replies
View Related
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
View Related
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
Nov 14, 2006
I have five columns, everyone with a header.
ABCD E
HD1HD2HD3 HD4HD5
2xsdwkj
3xsaer
4xre
5xtrwhj
6xhj
7xdf
8x
9xww
I use filter on the headers, HD1, HD2, HD3, HD4, HD5
If I use Ctrl+Shift+Down(arrow down) on HD1, I manage to mark all the x from row 2 until 9. If I do the same on HD5, it’s stops after the first one(kj). But I want to mark all the way down to 9, even the empty one, but it must not go any further than to 9, last cell I column A. Is there a shortcut for this on the keyboard, or can someone give me some tips on writing a macro witch does this.
View 2 Replies
View Related
Apr 14, 2007
I know you can click a cell in a range, type ctrl-A, and select the current (used) region. Can you do this for a column? Select a cell in the column, type (?), and select the usedcells of that column.
View 3 Replies
View Related
Jun 6, 2007
I want to write VBA code to select a cell in a row if one of the cells in that row contains a pre-define text. e.g. In cell A15 the text is Blackbird and A25 the text is Redbird. Sometimes this changes and A33 contains the text Blackbird and A19 the text Redbird. I want a VBA code that will select the cell in column E in the row that contains the text Blackbird. I must be able to specify the text and the column.
View 3 Replies
View Related
Sep 25, 2007
can a macro be used from the selected cell to select every other cell in same column? see attachment for before and after.
View 4 Replies
View Related
Jun 1, 2014
i am trying to figure out a vba code to select the last cell in column C that contains "Cgy".
View 3 Replies
View Related
Apr 27, 2009
Basically what I want to do is take any value that isnt "0" in column F and place it in another column in a nicely formatted table. So basically get rid of all the zeros...
Im sure this has been done and asked before but I have no idea what to search for or if there is some easy forumla in excel for situations like this.
View 9 Replies
View Related
Sep 10, 2009
the macro code to select the cell after the bottom of a column of data e.g. I have data in A1:A300 and I require the macro to automatically calculate the last row in the range (in this case A300) and then to select A301 (in this case)
(I know I can record a macro but the number of rows can potentially differ every time I run the macro)
N.B. Excel version 2003
View 3 Replies
View Related
Dec 30, 2013
. A B C D E
1 JanFebMarApr
2 Galle JGFGMGAG
3 Matara JMFMMMAM
4 KalutaraJKFKMKAK
5 PanaduraJPFPMPAP
6 ColomboJCFCMCAC
7
8 City Month
9 Kalutara Mar MK
When I type 'Kalutara' in A9 and 'Mar' in B9 I should get the answer as MK in cell E9
'Colombo' " " 'Feb' B9 " " " FC in cell E9 by refering the above table
can we use MATCH & INDEX or VLOOKUP & HLOOKUP
What is the formula I should write in cell E9 to get this done?
View 2 Replies
View Related
Apr 23, 2014
I want a simple macro which will go to the cell in row one in the active cell's column
View 2 Replies
View Related
Jun 25, 2014
I need to create a data base from figures extract everyday. I would like according the date to copy the figures in the sheet "Extractor" to paste in the column corresponding to the day of today in the sheet "Database". If possible as well, the figures of the dates before today must be delete (in the color tab)
I join a sample of what I have. I tried with the indirect function, but didn't find how to keep the figures of the previous dates.
View 2 Replies
View Related
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
Jun 8, 2008
I have an appoinment calendar that is one month per worksheet
- Column headings 09:00 - 20:00
- Row headings 'days and dates of the month' (split into two merged cells of two)
****************See attachment 'Calendar Format.jpg'****************
I have then created a UserForm which has two dropdown combo boxes
****************See attachment 'UserForm.jpg'****************
What I want to do is have a way of using the dropdown boxes to select a column and row reference to enter the other data into the four lines in the outlined box area (see Calendar Format.jpg)
I want to be able to select a date - and to have only the dates from the sheet showing would be a bonus! - and have the script use that as its row reference, followed by selecting the time and having it add the column reference, and so selecting the correct cell to be able to then add all the other pieces of data.
I would just set it up so that it all worked by selecting the first cell, then adding, but I'm worried about other users not doing that and so causing things to be misplaced or overwritten!
I'm more than willing to change most things, but I do need to have those four pieces of info, and I only need to have a simple calendar.
If anything is not clear, please ask and I'll try to clarify further!
Forgot to add - In the pics I'm using 2007, but I want to be able to run this on 2000/2003 as that's what's in the offices and it's going to be shared on the server.
View 14 Replies
View Related
Mar 4, 2009
If i have row 10-20 in column A filled, what vba code would i need to select a range in column C that selects rows 10-20
If that 10-20 rows in column A chnages to say 10-50 the vba code will select 10-50 in column C
View 10 Replies
View Related