Selecting The Whole Column As Range In Macro

Jul 17, 2008

I am working on a VBA macro, using the following



With wsSheet.Range("A:A")
ReDim MyArray(1 To .Rows.Count, 1 To .Columns.Count)
MyArray = wsSheet.Range("A:A")
For i= 1 To .Rows.Count
For j= 1 To .Columns.Count
wsSheet.Cells(i, j+ .Offset(0, 3).Column) = MyArray(i, j)
Next: Next

I want to select alla values in column A, but when I specify the range as "A:A" the code results in an infinite loop! How can I come around this?

View 9 Replies


ADVERTISEMENT

Selecting Range 6 X The Length Of Another Column?

May 15, 2012

I have a worksheet which already has some built in formulas which take the data in columns V and W, and use them to build other coding in column P. The trick is that the coding created in column P will be six times as long as the source data in columns V and W.

I.e., a single row containing "Sample1" and "Sample 2" in columns V and W respectively create the six following rows in column P:

Row 1:
Row 2: TMUnknown
Row 3: tested1
Row 4: Sample1
Row 5: Sample2
Row 6:

I want to be able to select the accurate length of Column P, which should be 6x as long as columns V or W. Any dynamic way to do this? (Since the amount of data pasted into columns V and W will change each time I use this worksheet.) I know how to select set ranges, but not how to adjust them as multiples of the length of another column

View 4 Replies View Related

Selecting Range Of Rows In Column

Sep 11, 2013

I want to select a range of rows 11, 14 and 23 to 24 in column j, plus the 2 rows to the right of column J and run a sum formula on the range. My procedure is selecting rows 11/14/23/24 and doing the sum for only column J. How do I make it so it runs the sum formula on all 3 columns. My code is copied below. I am fairly new to VBA.

Code:
With ActiveSheet.Range(Cells(27, j), Cells(27, j)).Select
Set sumRng = Intersect(Range("15:21, 25:25"), Columns(j)).Offset(0, 2)
ActiveCell.Value = WorksheetFunction.Sum(sumRng)
End With

View 4 Replies View Related

Selecting A Variable Column Range

Jun 21, 2006

I have a workbook that generates sheets for each year based on selected criteria. It starts at Column H and goes too AH and beyond. When my loop reaches Z it errors out. I think this is happening because the code is referencing the column as ASCII. Here is the

Sub Test()
Dim d As Date
Dim yrint, i, num_years, fields, field_start As Integer
Dim yrstr, crit1, crit2, left_column_range_fixed, right_column_range_fixed, left_column_range_var, right_column_range_var, left_column_range, right_column_range, cost_column, cost_column_var, cost_column_fixed As String
left_column_range_fixed = "H"
right_column_range_fixed = ":AH"
cost_column_fixed = "2"
crit1 = "=x"
crit2 = ">0"
d = Date
yrint = Sheets("Overall"). Range("H2")
field_start = 9 'changed from 9....................

View 4 Replies View Related

Selecting The 2 Last Values In A Column Of Data With Range

Jan 23, 2007

I m trying to make a button to add values to another sheet in my xls. Ive done that... now i try to autofill the percentages from left and above one row....

View 9 Replies View Related

Selecting A Range In Excel Macro

Jan 6, 2009

I have created the below macro to show the user (when he / she clicks on a button) how many days are left till the deadline day (taken from MS Project).

Sub DaysLeft()
Dim rng As Range
Dim count As Integer
Set rng = Sheets("Programme Reporting").[E2:E200]
count = Application.Evaluate("NETWORKDAYS(Today(),E3)")
Range("L3:L200").Select
ActiveCell.Value = count
End Sub

The range I want to output the days to is L3:L200 that seems to be okay. I have an issue with trying and putting a range in the NETWORKDAYS area, if I try and put in E3:E200 (the range of dates) it fails, as does $E$3:$E$200. At the moment the above code does work but it only puts in the days for one of the entries (E3).

View 9 Replies View Related

Selecting Dynamic Range Of Rows Macro?

Jan 28, 2014

I am trying to select rows in excel using a macro and then hide the rows, but i want to be able to add rows within this selection and still be able to hide the complete selection of rows.

The macro i am currently using is shown below: This hides rows 131 - 205, but if i was to add in another row in between so the range i now want to hide is 131-206 can i get the macro to update to this new range?

[Code] ......

View 10 Replies View Related

Selecting A Range Where Data Is Populated Using Macro In Xl

Feb 27, 2007

i want to write a macro which searches for data in a xl sheet.It should then format that data in a particular format.The data can be present in multiple places.For eg. formating a 5*6 matrix which starts from d4 cell and a 4*7 matrix which starts from e15 cell(please note that d4 and e15 location are not fixed).

View 9 Replies View Related

Excel VBA - Selecting Dynamic Range From Multiple Column Data

Feb 11, 2014

Selecting the range from Multiple Column data.

Currently, it is:

[Code]....

I have data from columns A:E

View 4 Replies View Related

Selecting All Data In Specific Columns Without Selecting Adjacent Column

Mar 10, 2014

Using VBA, I need to Select A1:C14.

The problem is that A1:C14 contains blank cells, and there is also an adjacent column D that I do not want to copy.

So, UsedRegion and CurrentRegion aren't doing it for me. (It selects Column D too.)

Obviously, this is an example...the real data set is an export and varies in size.

View 1 Replies View Related

Excel 2013 :: VBA Macro For Selecting Current Week Range

May 30, 2013

I currently have this beast of a code running in Excel 2013:

HTML Code:
Sub OBTAIN_RAW_DATA_MACRO()
Dim NextCol As Long

'Copy data
Workbooks.Open Filename:= _

[Code] ........

However the issue lies in that once the data is refreshed, the slicers reading off the above raw data/pivots, automatically select all weeks, however this is not beneficial for the data being presented.

Is there anyway to have, once the Pivots have been updated, for the macro to then check and select current week range (beginning Monday) only?

View 4 Replies View Related

Copy/Paste Range(s) Without Activating/selecting Range(s)

Oct 2, 2008

To initialize some cells/ranges, I am copying a given range and pasting it to another given range using the. Copy and .PaseSpecial methods. However, it would seem that both methods actually select the range(s) for the operations, i.e. the given ranges(s) are activated/selected thus changing the focus on the spreadsheet. I would like to perform both operations without actually selecting the given ranges.

View 5 Replies View Related

Subscript Out Of Range When Selecting Range In Closed Worksheet

Apr 28, 2006

I am receiving a 'subscript out of range' error on the lines of code below.

I would note that all variables are declared and all seem meaningful as regards what you would expect at that point.

Below is a snippet from the immediate window which indicates what the values are:
completecashname C:CashDevelopmentMyFolderoutputCASH042706.xls
cashsheetname Formatted Sheet
cashcurrcolumn A
cashfirstrow 2
cashlastrow 876

Also the workbooks are both closed at this point (but it makes no difference)

Set CashCopy = Workbooks(CompleteCashName).Sheets(CashSheetName). _
Range(CashCurrColumn & Cashfirstrow & ":K" & Cashlastrow).Value
Set PelPaste = Workbooks(completepelname).Sheets(PELSheetName). _
Range((PELCurrColumn & PELlastrow)).Value

View 8 Replies View Related

Selecting Unique Column Items Into Seperate Worksheet From Column

May 19, 2006

In the attached file, details sheet contains multiple instances of project with associated costs for each of 2006, 2007 and 2008. What I need is a formula (preferably) or a VBA that select distinct project names and populate column B of summary sheet so I can do a sum if. The problem is the project names changes dynamically every week and they are practically in hundreds.

View 9 Replies View Related

Selecting A Range Based On Date Within That Range

Sep 26, 2007

What i'm trying to do is select a range based on the date which happens to be in the first column of the range.

For example, I have a column (A) that contains dates and column (B) that contains names.

Its easy enough to select the entire range using

Range("A1:B4").Select

I need someting that will analyse column A and conditionally selct the range based on the date in column A (ie. it will only select the rows where column A has todays date).

View 9 Replies View Related

Selecting A Part Of Text From 1 Column And Put This In A New Column

Oct 22, 2013

I need to put a part of a text from a column and place it in a new collumn. At this moment I use 2 columns and an extra sheet to solve this.

I have a collumn with a lot of data like:aaa-bc

bbb
abc-ba-bd
aa-bb
bbb-xx-yy
aa
abc-yy
klmn-zz
klmn-yy-ff

What I need is behind every cell a new cell with only the 1st part like:aaa

bbb
abc
aa
bbb
aa
abc
klmn
klmn

What I do now is use a new column with this formula:

[Code].....

And I made a translation table in which the 1st 4 characters are translated to what I want to see. In a 3d column I use

[Code]....

to get the results I need. Since I need to get results like this very often this method is very time consuming.

Is there a formula available I can use with only 1 new column?

View 2 Replies View Related

Selecting From One Set Range To Another

Jul 11, 2014

So in my code I have two set ranges and want to select from one set range to another. The code I have now does not work because I cannot select Range("POBRF:PO"). This is the code.

[CODE]
ARow = Range("A" & Rows.Count).End(xlUp).Row
Set POBRF = Range("A1:A" & ARow)
BRow = Range("I" & Rows.Count).End(xlUp).Row
Set PO = Range("I1:I" & BRow)
Range("POBRF:PO").Select
[CODE/]

View 1 Replies View Related

Selecting A Range Using VBA

May 28, 2009

I am having trouble selecting a range in my data to copy to another worksheet. I have declared two variables (startcell and endcell), as seen below, as strings:

Cells.Find(What:=startdate, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

startcell = ActiveCell.Address

Cells.Find(What:=enddate, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

endcell = ActiveCell.Address

After this I would like VBA to copy all the variables in a range that is bounded by startcell and endcell. Here is what my code is currently for selecting the range:

Range("A2:" & endcell).Select

Instead of A2, I would like to select startcell, but I cannot figure out how. Currently I can get VBA to recognise endcell. For example, using the formula above I can copy the range from A2 to endcell. However, when I try and use startcell as the beginning of the range (in place of A2) the code does not work.

View 9 Replies View Related

Selecting A Certain Range That Changes

Jan 17, 2007

I have two tables in two different worksheets. In the first table, rows get deleted if the value in column 'S' (the first row to the right of the table) is not '1', and columns get deleted if the value in row '2' (third row above the table) is not '1'. In the second table, the number of columns stays always the same but rows get deleted if the value in column 'N' (first column to the right of the table) is not '1'.

After the rows and columns are deleted the tables get pasted in a ppt presentation.
Now the problem: I am a beginner in VBA and up til now I am only able to define a certain Range, e.g. ("A5:M17"), to be copied and pasted into ppt. But since the tables will sometimes be bigger than other times depending if rows/columns are deleted, I would rather define a dynamic Range. The top left cell of both tabels to be copied is always 'A5' but the bottom right cell changes.

View 2 Replies View Related

Selecting A Range And Then Summing That Range

Jul 19, 2006

I am trying to select a range of numbers based on an active cell. I then want to sum those numbers and have that total reported to a specific cell.

For example:

Say I have a column with a list of dates (Jan/04 thru July/06). I want the user to be able to click on any given field and have that field plus the 11 fields above it summed and reported. Any help?

I came up with something like

ActiveCell.Resize(12, 1).Select

This only selects the data from the active cell and goes down...I need the opposite. I need it to select the 11 cells above the active cell (plus the active cell) and sum that data.

View 4 Replies View Related

Selecting A Column

Jan 28, 2010

I need to select the whole column ABOVE the active cell. Ctrl-Shift-UpArrow is no good because it stops at the first blank cell. And selecting the whole column is no good either because when I subsequently paste into the column, it pastes in all the empty cells of the column, meaning my worksheets expands from a few hundred rows to 1 million!

Shift-Home does what I want on rows. Is there an equivalent for columns?

View 9 Replies View Related

Selecting More Than One Column

Oct 4, 2013

Cells(xrow, 3).Select --

Is there any way I can select more than one column.

I tried Cells(xrow, 3:10).Select but it gives error.

View 3 Replies View Related

Selecting Column By Its

Jul 3, 2008

I wrote a Macro that select info from Worbook "A" to Workbook "B". In that Macro tha columns B:B, E:E and F:F are selected.

The problem is that the layout is not always the same so the correct columns keep shifting positions. The only thing that never changes is the "Column Label" in the first Row.

So, no matter from which column I alway have to copy: "Order Date"; "Status" and "MetofPay".

Is there anyway to tell my macro to look for those columns instead of B:B, E:E and F:F?

View 9 Replies View Related

Selecting Specific Value Within A Range

Nov 12, 2008

I have a spreadsheet with Employee details and each employee has a Indicator and a Score.
I'm battling to get Excel to do a lookup on the Indicator, find the applicable Score Range, see if the individual's Score falls within the range and then inserts the relevant % into a cell in a specific row of each employee.

If we did not have more than 2000 doing it manualy might have been an option. Also, the Percentages and Score Ranges in the matrix might change a couple of times....

View 6 Replies View Related

Selecting Range Up To Blank Row

Feb 8, 2009

I am having a few problems selecting a range. What I am trying to do is select a range where the number of columns stay the same, but the rows are variable; ranging from one row upwards. At the end of the rows, there is a blank row. I currently have;

View 2 Replies View Related

Selecting Range Of Cells

Jan 31, 2009

I am trying to select a range of cells. The range I need to select starts in Cell A1. I need to select every row with data in column 1 up to the first row with no data. I then need to expand the range to all columns up the last column with data, including columns with blank cells.

The problem with my code relates to the selection of columns. It is only selecting up to column F. Column G is empty, Column H has data, Columns I-J are empty, Columns K-R have data.

View 5 Replies View Related

Selecting Range With Variable Row?

Apr 4, 2013

I want to copy a range where the row is variable (i in the Loop I'm doing) but the columns stay the same. What am I doing wrong?

Workbooks("Labor Info").Sheets("Transfer").Range("A" & i & ":E" & i).Select

View 1 Replies View Related

Selecting All Pictures In Certain Range

May 13, 2013

I was trying to select all of the pictures/objects in a certain range (A294:L1400) in order to move them all at the same time. How do I do this?

View 1 Replies View Related

Selecting A Range Using Variables

Jun 23, 2008

How would I select a range using variables? For example, say I wanted to say

myRange = Sheets(1).Range("A1:A100"),

but the column was variable. How would I do this if the column number was stored in a variable?

View 9 Replies View Related

Selecting Variable Range

Feb 26, 2009

I need to select starting with:.

Columns A-O
Rows 1 - ( LR of ColB - Col A is empty )

View 9 Replies View Related







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