Select Columns By Number

Sep 27, 2007

an equivalent to the code

rows("8:10").select

for columns. I don't want to use the A, B notation but rather, column numbers.

View 6 Replies


ADVERTISEMENT

Select Number Of Columns

Apr 1, 2014

I want to select a number of columns. I know the column indexes.

I want to use something like (Doesn't work):

[Code] ......

Instead of (Works):

[Code] ....

Rows can be selected according to:

[Code] ....

I have written this code that works. But there must be an easier way:

[Code] ....

View 4 Replies View Related

VBA - Select Row Number From Input Box And Delete Specified Columns From That Row

Jun 11, 2013

I have an input box which asks the user to select a row that they wish to delete.

What I need to do is take the row number that has been selected and delete cells B:K and move the below cells up.

View 1 Replies View Related

Select From Multi-Select Listbox And Get Index Number?

Oct 30, 2012

I have a multiselect listbox with values that gets populated from a sql statement, and I would like to get is the first or second index from the selected item. I know how to get the listindex from a combobox by using:

VB:
cbnumber.List(.ListIndex, 0)

How can I loop through and get the 1st index number for the selected items only from the listbox? I want to pass this index number to another sql statement.

View 5 Replies View Related

Select Last Number In A Row That Contains Number Greater Than Zero And Return A Value

Feb 14, 2014

[Code] ......

How to create a formula in cell M2 that looks at the second row of numbers (0 and 500s) and tells me the rightmost value that is greater than zero. In this example it would return 12.

Second Question: Is there a way to return any counted value, for example the second-to-last number that is over 0?

View 2 Replies View Related

Select Multiple Columns In VBA

Nov 1, 2012

To select multiple columns I can use Union but can I use something that will cicle through the values from an array?

Example (how do I see this)

VB :

columnsToDelete= array("UM","Post","Pre")
For i=0 To UBound(columnsToDelete)

Set columnsFound=Range("1:1").find(what:=columnsToDelete(i), lookin:=xlvalues,lookat:=xlwhole, matchcase:=True)
columnsFound.select
Selection delete
Next i

View 2 Replies View Related

Select Multiple Columns

Sep 15, 2008

I am using VBA to change the format of columns. The code work with 1 column, but In need to change the format of mulitiple columns. E.g Cols 11 to 22. I tried the code below but it does not work!

View 3 Replies View Related

Select Range Of Columns

Jun 26, 2009

I'm in the midst of preparing a Year-To-Date (YTD) simple financial report in MS Excel.

Firstly:
I allow user to enter a number in cell A2.

Secondly:
Cells from A4 - L4 are linked from Sheet1. Cell M4 will give sum of A4:L4. Users are not allowed to change data in cells from A4 - L4. Users are only required to enter a number between 1 to 12 in cell A2. Upon update cell A2, the VBA shall sum the number of columns as entered in cell A2.

For example, if user enter 3 in cell A2 then cell M4 must give sum of A4:C4. If user enter 8 in cell A2 then cell M4 must give sum of A4:H4.

View 9 Replies View Related

How To Select Number Not Already Used

Aug 4, 2013

I have a competition in bowls format where mats are selected each round so that players do not play on the same mat twice. I was hoping to find through search, where the number selected was never repeated not so far.

I have 32 mats to chose from in one comp, but others can vary from 4 to 24. how to start via vba or formula would be welcome.

if 2 players have played on mats 2,4,8,6 and 12,14,16,18 can a formula check the numbers used and select one that has not been used so far?

View 4 Replies View Related

Macro For Spreadsheets With Different Number Of Rows And Constant Number Of Columns?

Mar 1, 2014

I work on a daily basis with spreadsheets in excel. The number of columns is the same, but every single spreadsheet has a different number of rows. I recorded this macro in a table with 1196 rows and I would like to use this macro also in other tables with a different number of rows.

Sub City2()
'
' City2 Macro
'

'
Selection.Copy
Cells.Replace What:="POMPANO", Replacement:="Pompano Beach",

[Code].......

View 12 Replies View Related

Select Specific Columns Rather Than Entire Row

Sep 28, 2013

I plucked a macro off an old post from here (as I always do), but I'm having trouble tweaking it.

VB:
Sub completedtest()

Dim c As Range
Dim rngG As Range
For Each c In Intersect(ActiveSheet.UsedRange, Columns("i"))

[Code] ....

As it currently stands, the macro selects the entire row of rows containing the letter Y in column I. All I need to change is, I want to simply select columns B through I, rather than the entire row.

View 2 Replies View Related

How To Select Data Entries From 2 Columns

Jul 29, 2014

I have a large spreadsheet of species activity data and want to separate information from two columns to create a bar chart of when a certain species is active over a 24-hour period. There are duplicates of each species in one column and a unique corresponding time of activity for that species in another, something like the following:

Species A 23:01
Species B 07:09
Species C 13:45
Species D 08:30
Species A 01:55
Species A 22:07
Species C 15:29

What formula can I enter that only selects Species A and their corresponding times that I can copy into a new spreadsheet?

View 2 Replies View Related

Select And Print Used Pivottable Columns?

May 21, 2014

I would like to somehow select and print the used columns in my pivot table.

I currently have a code that prints TableRange2 but this also includes blank pivot tables columns which are not in use.

View 2 Replies View Related

Select Blanks In Columns That Contain Dates

Jun 30, 2014

Please see attached.

What I would like to do is for each column within range("a1").currentregion that has dates, select the blanks in those columns and put the date 1/1/1900.

The result is in the Result sheet.

I know how to do a standard loop through columns but I'm not sure how to do this for just the current region and just for those columns with dates.

View 2 Replies View Related

Select All Non Blank Data In Columns

Nov 7, 2008

I need to select all data in columns A:F but the number of row containing data is variable. I need to select only the rows with data.

View 7 Replies View Related

Select Columns To Merge Within For Loop

Nov 18, 2011

My issue is I want to use a for loop to go through a spreadsheet. Within the for loop if a certain condition is true I want it to select all columns from A to AW and merge them together.

Example of what I have so far:

Sub MergeHeaders
dim i as Intger, LastRow as Integer
LastRow = Cells(Rows.Count, "CP").End(xlUp).Row
For i = 1 to LastRow
'Check if the leading character is a letter, not number
If Asc(Cells(i, "AP")) > 64 Then
'I want select from A to AW only for current row i, then merge
end If
next i
end sub

View 1 Replies View Related

ADO Select Distinct Multiple Columns

Aug 5, 2009

I am using ADO to select data from a CSV file, column 1 has some duplicate Incident numbers, but the rest of the columns the data may be different but not interested in that so I cannot use SELECT DISTINCT incident, desciption as this applies to all columns

so I tried the following

StrSQL = "SELECT DT.IncidentNumber, ST.Description -
FROM (SELECT DISTINCT IncidentNumber FROM " & StrFile & " ) DT -
INNER JOIN " & StrFile & " ST ON DT.IncidentNumber = ST.IncidentNumber"

however it returns ALL rows, if I use just

SELECT DISTINCT IncidentNumber FROM " & StrFile

I get the rows I am interested in but not the extra data I require

View 9 Replies View Related

SQL (Select All) Not Picking Up A Number

Jan 5, 2012

I have a CSV file which contains a list of records about offices. This CSV file is generated from another program.

I read the CSV file with VBA, a SELECT * SQL statement which puts the elements into an Office Object and adds the offices to a collection.

For some reason, when one of the Telephone numbers is read it is being identified as a Null value. If I manually open the CSV file and change it to a different number e.g. 12345 and try re-read the CSV file with SQL VBA the number gets read fine. Every other element in the CSV file reads fine except for this. The number itself is 7736786460.

Attached is the small snippets of code to read the CSV file which is fairly straightforward.

Code:

Sub LoadUnits()
Dim oRs As Recordset
Set oFSObj = CreateObject("SCRIPTING.FILESYSTEMOBJECT")
'Open an ADO connection to the folder specified
Set oConn = CreateObject("ADODB.CONNECTION")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strFilePath & ";" & _

[code]...

View 7 Replies View Related

Random Number Select

Feb 5, 2007

I need a macro that will select a random number between 1 and 6. ie select the number of a dice. It needs to input 1 random value into one cell and another random value into another. Like the dice values of a monopoly game.

View 9 Replies View Related

Select Row Using Variable Row Number

Apr 17, 2008

I don't know how to concatenate a string within the Rows function. I want to be able to vary the row number with a variable, but I don't know how to construct the string, especially given that one of the delimiters within the function is ".

View 3 Replies View Related

Multi-Select Listbox Selections To Different Columns

Feb 11, 2014

I am currently setting up a userform where one of the options is for an error code (chosen from a listbox) but the user has to be able to select multiple codes. I have the below working if it is NOT multi select, works a dream and goes in the right column.

VB:
If ListBox2.Text = "A1" Then
LastRow.Offset(1, 20).Value = "x"
ElseIf ListBox2.Text = "A2" Then
LastRow.Offset(1, 21).Value = "x"

But as soon as I set it to mutliselect and choose say A1 and A2 neither one writes, I imagine because Listbox2.text is now A1,A2 and not just one or the other.

View 9 Replies View Related

Transpose Function - How To SKIP / SELECT Certain Columns?

Feb 3, 2014

I am working on a =transpose function. Pretty simple right? Well now I am trying to have it SKIP/SELECT certain columns.

I have =transpose("date!B1:T1"), but now I want to "Select A,B,D,E,F"

=TRANSPOSE(INDIRECT("date!B1:T1"),"select A,B,D,E,F,G,H,P,Q,R,S,T")

View 1 Replies View Related

Sorting Columns - Select Lowest For Calculation

May 12, 2014

I am trying to find a formula that will look at the figures in four columns and then select the lowest for the calculation.

Basically what I am doing is getting venders prices and placing them in the column. The cheapest is then selected.

Showing which vender is used would be a bonus.

View 1 Replies View Related

How To Select Range And Skip Over Hidden Columns

May 1, 2014

I have below a code that is selecting from A11 down as far as there is data and across a certain number of columns then sets a print area.

Currently the columns go A, B, JW, JX, JY, JZ, KA, KB as C through to JV are hidden. I have tried to offset the columns by 7 to see if it will select A-KB but it is selecting cells that are hidden and only selecting A-G. I need it to go past the hidden columns. Here is the code:

[Code] ......

Could I also get a code to go from A10 and move over to KB and create a range from there e.g. KB-KJ and last row from there?

View 10 Replies View Related

Dynamic Range To Select Only Visible Columns?

May 6, 2014

I need a macro to start at cell A11 and select across 10 columns and down to the Lastrow (last row with any data).

There are hidden columns after column D so it CANNOT have any columns hardcoded except for column A.

This selection then needs to be set as a single print area to print out on 1 page. I have already set Rows 1-10 as a title area to print at the top of each page.

Code i currently have is:

[Code] .......

I just need it to now go across 10 visible columns and set as a single print area.

View 8 Replies View Related

Select Alternating Columns With Unknown End Point

Feb 18, 2010

so I have been googling to figure out how to write a macro that will select every other column on my workbook. All that keeps coming up is conditional formatting, which I do not want. I am not trying to highlight the columns in alternating colors, I just want to select them.

I am starting at column F and I would like it to search until the end of the columns and select every other column ending with the last column with data in it.

I know I could search by a specific row and tell it to find the first blank cell then offset it, but there is no particular row that will always have data in it, so I guess it needs to check by column until it finds the first column without any data in all rows and then offset it.

Anyone know what I am talking about here?

I know it should be fairly simple but I couldn't seem to find any answers anywhere else.

Also, anyone know any good websites that have definitions for some basic macros? I'd love to start learning how to write this stuff on my own.

View 7 Replies View Related

Select Cells Across Multiple Columns On Variable Row?

Nov 25, 2011

I'm trying to write some code to select cells in a number of columns on a variable row. I have the following code to define the rownumbers for Cash and Pal:

Columns("G:G").Select
Selection.Find(What:="Total Cash", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _

[Code]....

Then I can use the following code to select a cell in a single column:

Range("P" & Cash & ":P" & Pal).Select

but I need to select cells in columns P, R, T, V, X, etc.....

If I was doing this for a fixed rownumber I would use:

Range("P22:P23,R22:R23,T22:T23,V22:V23,X22:X23").Select

but because my rownumber is variable I tried to use:

Range("P" & Cash & ":P" & Pal, "R" & Cash & ":R" & Pal, "T" & Cash & ":T" & Pal, "V" & Cash & ":V" & Pal, "X" & Cash & ":X" & Pal).Select

but this doesn't work giving the Compile error: Wrong number of arguments or invalid property assignments

View 4 Replies View Related

Select Range Of Columns And Unhide Any That Are Hidden

Dec 10, 2013

I have a macro that allows me to select a range of columns and unhide any that are hidden. I am on the sheet "Employees", but the action happens on the sheet "Enter". I can run this macro when I am on "Employees" and jumps top "Enter" and works exactly as I want it to.

Code:
Sheets("Enter").Select
Columns("B:T").Select
Selection.EntireColumn.Hidden = False
Range("M8") = Sheets("Employees").Range("B5")
Range("I7").Select

But when I try to run it as part of another macro that begins on "Employees", I get "Run-time error '1004': Select method of Range class failed", and Columns("B:T") is highlighted.

View 4 Replies View Related

Select Columns To View In Large Spreadsheet

Oct 3, 2008

I have a large spreadsheet with over 50 columns but usually only need to view a small selection of them. Many colleagues use the sheet and often use the format, hide, column function to hide columns they do not need but then the next user has to unhide them and re-hide others until they are left with the different columns they require.

Is there anyway of creating a menu which allows users to select from a list of all the columns those they wish to display, all the others therefore being hidden.

View 9 Replies View Related

Randomly Select Rows, Columns Or Ranges

Oct 18, 2006

by what means is it possible to unselect randomly selected areas, rows, columns from all sheets?

View 4 Replies View Related







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