VBA Sorting Nth Range Not Working

May 16, 2009

I have a values in column C of stuff1, stuff2 and on down.

I have a value in cell A1.

I want to start in C1, and every Nth, where N is the value in cell A1, select and paste into column H.

My problem is that the selected cells don't start in C1, in fact, based on the value in A1, it starts in different cells in column C. AND, if i press the button twice, the returned values are different.

View 14 Replies


ADVERTISEMENT

Sorting A-Z Not Working Properly

Sep 3, 2013

I am including an attached file for reference.

The file is sorted A-Z, but if you scroll down towards the bottom, you will see that some values are out of order. Both instances of University of Central Florida and University of North Dakota are out of place.

University of Central Florida should be between University of California and University of Colorado.

University of North Dakota should be between University of Colorado and University of Southern Mississippi.

View 1 Replies View Related

Working With Text (Sorting And Address File)

Apr 3, 2007

I have a list of about 300 addresses that I'd like to be able to put in a sortable state. In column A1-A4 is the following:

Name
Street Address
City, State Zip
Email Address

Then there is a blank row and then the next address. What I would like to do is figure out a way to take the info in columns A1-A4 and move them horizontally to A1, B1, C1, D1, respectively. Sure, I could cut and paste, but it would take me forever. I tried a macro,

View 9 Replies View Related

Sorting A Range Of Numbers?

May 28, 2014

I'm attempting to create a formula that'll sort a range of numbers and then return the corresponding values based on a specific place within the sorted range.

In this case, I'd like the following numbers sorted smallest to largest:

15, 9, 11, 19, 22, 17, 24, 19, 17, 24

The result would return something like:

9, 11, 15, 17, 17, 19, 19, 22, 24, 24

Then I'd like it to return the value based off of the formula in cell U13 & U14. In this case, it'd return the value in the 2nd and the 9th position (bolded above). I tried to use INDEX(), but it's returning the values in the unsorted list. I'd like it to return values from a sorted list. Also, I'm trying to solve this using a formula (not Sort & Filter) or VBA.

View 1 Replies View Related

Sorting A Dynamic Range?

Feb 20, 2013

I am trying to doctor a recorded sort macro to adapt to a changing range.

With the code below I get:

RunTime error 1004
Application-DEfined or Object-Defined error

I have tried with no luck:

Key:=dat
.SetRange dat
Key:=Range("A1").Resize(rw, clm)
.SetRange Range("A1").Resize(rw, clm)
Key:=Range("dat")
.SetRange Range("dat")
Key:=Range(dat)
.SetRange Range(dat)

[code]....

View 1 Replies View Related

Sorting On Column Within Range?

Nov 5, 2013

I am trying to sort a range of data by 1 column (column D), and get the following error:

"The sort reference is not valid. Make sure that its within the data you want to sort, and the first Sort By box isnt the same or blank."

Having googled and also checking some previous posts, I thought the issue may be around qualifying my key to ensure that I used the active sheet, but having done this, I still get the error.

CodeRange("A2:V2", Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Overview").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Overview").Sort.SortFields.Add

[Code]....

View 3 Replies View Related

Sorting A Range Of Cells

Jan 10, 2008

I am using Excel 2003 and am after a macro that can sort a specific range of cells.

I have a spreadsheet that is used to record details of photos taken during bridge inspections.

•The details of the photos are recorded in column B
•The number of the digital photo is recorded in column C (the number of photos taken per inspection varies)
•After checking by someone else the photos are assigned a number in column A

After two blank rows that process is repeated for another inspection.

I am after a macro that when a cell within a range/block is selected it will sort columns A:C by the numerical order of the range block within column A.
For example when any cell is selected within the range A3:C7, that range and only that range will be sorted.

The same would happen when a cell is selected within range A11:C15, and so on....

View 9 Replies View Related

Sorting Out Duplicate Values From Given Value In Range

Jul 9, 2009

example

1
2
3
1
2
6
4
3
6
7

In the Above range i want excel to show me
how many items are duplicate

If the duplicate item is shown i want the result to be shown in next cell

LIKE in the above example i want excel to show 1 is common , 6 is duplicated twice and therefore result should be shown in next cell

View 14 Replies View Related

Recorded Sorting Defines Set Range

Jul 14, 2006

I've noticed (a bit to late) that if you record with macro recorder a sorting statement that a range is captured. Because my files do vary in recordcounts, how can I sort indepently on the number of records.

View 4 Replies View Related

Keep Named Range With Values When Sorting

Jul 2, 2007

I have Excel 2003 with named cells, for example...

cell cell name data
A1 AAA 3
A2 BBB 1
A3 CCC 2
and so on...

When I autofilter (ascending) these cells, the data in these cells sort correctly, but the cell names stay where they're at.

cell cell name data
A1 AAA 1
A2 BBB 2
A3 CCC 3

I'm not an Excel expert so I'd like to know is there any way I could get the cell names to sort with their data.

cell cell name data
A1 BBB 1
A2 CCC 2
A3 AAA 3

View 6 Replies View Related

Sorting Table Of Data - Selected Range Only

May 30, 2014

I have some data formatted as a table. There are some blank rows at the end that still contain formula.

Every time I sort the data these rows move to the beginning. I have tried only selecting the active rows of data, but the whole lot defaults in each time

How do I sort data with a selected range only (within a table)?

Don't really want a macro as this will need to be used by others

View 1 Replies View Related

Sorting Range Based On String Variable

Jul 31, 2014

I have a spreadsheet with column headers like, "Date" "Phone number" "Name" ect., and rows of data below. Each of these rows contains data pertaining to a prospect employee, as the purpose of the spreadsheet is to keep track of job applicants. One column is used as a 'Recruiter Sign-off' area, where the recruiter who processed the application inputs their name:

Example.png

I'm trying to automate a variation of excels sort function. However, I don't want to sort 'From A to Z.' Instead, I want to have the rows of data sorted with the 'Recruiter Sign-off' column used as the sort Key, and a selected name (of one of the recruiters) used as the sort Criteria.

I already have a userform that allows the user to select a name from a listbox. When they press confirm, the name is stored in a Public String variable, (selectedRecruiter). I'd like then like to have the rows below the column headers to be sorted based on the selected name. Example: User selects the name "Jon" from a list. The application then brings all of the applicants that 'Jon' has signed off on (those rows that contain his name) to the top rows of the range.

The workbook is shared, so I cannot use tables.

I found a code that accomplished what I want, however it also leads to a horrible system crash after a few times running it (BEX crash).

[Code] ..........

View 3 Replies View Related

Range Is Not Working

Apr 13, 2009

i dont know what's wrong with these lines:

View 3 Replies View Related

Find Top Equivalent Values In Excel Range Without Sorting?

Mar 29, 2014

I know the formula =large but my problem is the formula for the equivalent value for it. Note: In my xcel file attached you can see there are multiple items with the same total numbers and also blanks

View 3 Replies View Related

Range Sort Not Working?

Jun 27, 2014

I'm highlighting a range and then sorting column F from Largest to Smallest. The macro doesn't sort it at all. Added my code tags.

View 1 Replies View Related

Range Select Not Working?

Feb 17, 2012

The code works up the If statement and I'm not sure why.

Code:
Private Sub SalesRedeemed_Click()
' Open SalesRedeemed Worksheet move to next month
Sheets("SalesRed").Select
Sheets("SalesRed").Range("B5").Select
If Range("B5") > 1 Then
Sheets("SalesRed").Range("B6").Select
End If
End Sub

View 9 Replies View Related

Working With A Variable Range

Feb 14, 2009

My MACRO is used daily to copy data from several sheets resulting in a new sheet with a differing number of rows with every run. My problem is that I need to define this range of rows in order to do an AUTOFILL function.

I know I can use a cell to hold the row count using COUNTA. However, I cannot figure out how to then use the result of this in the range statement.
example using COUNTA within cell D100 produces a row count of 95

My MACRO needs to do the following:
A1 =Month(C1)
B1 =Year(C1)
Range("A1:B1").Select
Selection.AutoFill Destination:=Range("A2:B????"),

View 9 Replies View Related

Indirect Using Dynamic Range Not Working

Dec 27, 2012

In the example I have attached there are two sheets, Details and DataTables. There are also a number of named ranges, both static and dynamic, that refer to data on the DataTables sheet. Most of the static ranges were added for debugging purposes. The tables have been shortened for this example.

On the Details sheet column A has a drop down that allows you to select the make of a device. Column B builds its drop down list based on what is selected in column A. The data validation in B2 uses a named dynamic range and the drop down does not work. The data validation in C2 used a named static range and the drop down works.

Column C will fill in the RU value based on what is selected in column B. Cell C3 uses named dynamic range and it does not work. Cell C4 uses named static range and it works.

I would like to used named dynamic ranges if possible so when data is added to the tables the named dynamic ranges will self adjust. Can what I want to do be done?

Dynamic Range.xlsx

View 8 Replies View Related

Date Range Formula Not Working

Apr 14, 2014

I am trying to create a formula that if the date column falls between 01/01/2014-01/25/2014, it returns January as the value.

View 10 Replies View Related

Date Range Formula Not Working?

Apr 14, 2014

see the attached spreadsheet, I am getting an error message with the attached formula

View 2 Replies View Related

Named Range Not Working In Some Functions

Apr 29, 2012

I have a problem using a named range as an arg to worksheet functions.

First, I create 2 end point names for the range, myStart, myEnd.
Then I create a named range myRange = myStart:myEnd

This formula in a cell works: SUM(myRange)
This formula doesn't: COUNT(myRange) . It crashes Excel, requests Restart.
But these work: COUNT(myStart:myEnd) and SUM(myStart:myEnd)

Why does SUM work for either set of args, but COUNT only works for one set?

Here is the F3, PasteList output:

mFirstCol =mFirstColMinus1+1
mFirstColMinus1 =COLUMN(Sheet1!$A:$A)
mInsertCol =COLUMN(Sheet1!$B:$B)
mLastCol =MAX(mFirstCol, mInsertCol-1)
mNumberCols =mInsertCol-mFirstCol
mRowEnd =INDIRECT(ADDRESS(1,mLastCol))
mRowRange =mRowStart:mRowEnd
mRowStart =INDIRECT(ADDRESS(1,mFirstCol))

View 4 Replies View Related

Range Content Removal Not Working

Aug 24, 2012

what is wrong witht his code?

If Sheets("Workings").Cells(ExceptionCount, ColumnCount + 3).Value = 1 Then
Sheets("Allocations").Range(.Cells(ABIndex + 5 + week, (ColumnCount * 7) - 5), .Cells(ABIndex + 5 + week, ColumnCount * 7)).Value = ""
Else
End If

I know the If statement is working, but for some reason I can't fathom the line that removes the cell contents does nothing. I have tried ending with .ClearContents rather than .Value but that doesn't work either.

View 7 Replies View Related

2007 / Range(Cells(n,n)) Not Working

Sep 13, 2008

I've worked with Excel for many years and have just begun writing VBA in Excel 2007, so I am really stumped by this:

SR = 1
SC = 1
TR = 40
TC = 2

Worksheets("ChartData").Activate

' Works
ActiveSheet.Range("A1:B40").Select

' All of the following Fail w/1004 Error
ActiveSheet.Range(Cells(1, 1)).Select
ActiveSheet.Range(Cells(1, 1), Cells(40, 2)).Select
ActiveSheet.Range(Cells(SR, SC), Cells(TR, TC)).Select

At first I thought I had a bad install,
but this is happening on two manufacturer installed systems...
And I seem to be following the documentation for the use of Range with Cells.
Am I missing something?

View 9 Replies View Related

Working With A Subset Of A Named Range

Dec 19, 2008

I have a sheet of data that is imported from an external database. Depending on which report gets imported, the column count and column location will vary. However, the headers for the columns I need to work with are constant, therefore I create a named range for all columns, and reference the ranges as I work with the data and avoid hard-coded cell references. Therefore, the ranges are one cell wide, with up to 2000+ rows.

Here's my problem. I need to reference a sub-set of a named range, to get the min of the subset. I've searched this board and others, but can't find an example of this method. The code is within a loop, and the range subset location is determined by a count on another named range.

The data involves Tasks and Subtasks. Each task can have multiple subtasks, and each subtask has it's own start and end dates. I'm trying to determine the earliest start date and the latest end date for each individual Task so I can determine the total duration for the Task.

Here's the code that determines the cell range. This code is working.

d2 = WorksheetFunction.CountIf(Range("ASR"), Range("ASR").Cells(y, 1).Value) ' count number of tasks in this ASR, store in d2

The code that I can't figure out is below. The compiler can't figure out what I'm trying to do. (Neither can I!!)

d3 = WorksheetFunction.Min("Planned_Start_Date").Cells(y, 1), Cells(y + d2 - 1, 1).Value) ' Get the min Planned Start Date for this ASR

In english: Look in the Planned_Start_Date named range, and more specifically a certain subset of that range, and return the minimum date found.

I've tried several ways, none of which will compile. I realize the above code is way off; I include it to show how lost I really am!

Slightly off-topic: I'm fairly new to VBA, and am expected to create executive dashboards with the data. I've purchased Excel 2003 Power Programming with VBA and Excel Charts (both Walkenbach); Excel Programming 2nd Edition; Excel Edition of Using Visual Basic for Applications; and Dashboard Reporting with Excel, Kyd. These are all useful books, but I think they expect me to have a better understanding than I have.

View 9 Replies View Related

Working With Recordset In A Range Of Cells

Oct 14, 2006

how i can display different values using the Selection.FormulaArray, ok look at my
Dim mySheet As Worksheet

' On Error GoTo errors
Dim x As Integer
x = TextBox1.Text
Dim y As Integer
y = RefEdit2.value

Set mySheet = Excel.ActiveSheet
mySheet. Range(RefEdit1).Select

Selection.FormulaArray = "=multiplie_value(""" & x & """, """ & y & """)"
MsgBox Selection.FormulaArray

Now the function i call:

Public Function multiplie_value(valor As Integer, multiplo As Integer) As Integer
multiplie_value = Val(valor) * multiplo
End Function

thats an example. so the real question is i create a form, the user enter some values to search to a database, the user select an area(a range) where they want the data to be display, but i dont how to display that info that is coming from the database in the range that the user selected. The info displayed in the range should look like a tabular report, column headers, etc.

View 9 Replies View Related

Variable Column Range Based On Current Selection For Sorting Columns

May 16, 2014

The first line of the code chooses the columns to select; all columns until there is no value. From there I need to have it sort those columns based on row 1. The problem is that the columns chosen are variable. It could be columns I:N (as shown below) or column G:Z or any other combination. (The code below was recorded if that matters at all.)

View 2 Replies View Related

Compare Formula (For Vertical Range) Not Working

Feb 21, 2014

I am trying to compare vertical range "A" in sheet1 to vertical range "K" in sheet2 if they match to copy both rows and place in sheet3. I have tried the following but it did not work.

Sub Searching()
Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
' create short references to sheets
' inside the Sheets() use either the tab number or name
Set sh1 = Sheets("Sheet1"): Set sh2 = Sheets(2): Set sh3 = Sheets(3)

[Code] ......

View 1 Replies View Related

Cells Range Reference Not Working Properly

May 25, 2009

I often have problems with the cells range reference method. For some reason I get an error and can't tell why. Other times it works fine. Is this just an unstable method to use or is this completely wrong? I'm assuming I am using the wrong syntax. It is definetly the range reference causing the problem.

Dim cnt1 as integer, cnt2 as integer,cnt3 as integer

cnt1 = 2
cnt2 = 50
cnt3 = 2

dim myrange as range

set myrange = sheets("sheet1").range(cells(2,cnt1), cells(cnt2,cnt3))

I have no idea why it won't work. I'm basically searching a columner range of cells.

View 2 Replies View Related

Sumifs With Month (range) Criteria Not Working

Aug 14, 2013

I am trying to create an equations that sums up a range based on matched dates. I have considered using an array, but that turned out to be much more work than necessary.

I have never used the SUMIFS before and having trouble, here is the equation I'm using.

=SUMIFS($F$2:$F$204238,MONTH(E2:E204238),"=month(referenced_range)")

*F2:F204238 is the range that needs to be summed up
*the month(referenced range) is in date form
*I was able to pull and evaluate all the data on it's own, but when using it in the sumif equation it gave me zero result so it must be a syntax error.

View 3 Replies View Related

INDIRECT Not Working For Dynamic Named Range In SUMPRODUCT

Feb 11, 2012

The formula is =SUMPRODUCT((Group="A")*(Project_Description="Long Term")*(Profile="B")*(INDIRECT(B9)="x"))

B9 through M9 have header text Jan_2012, Feb_2012...Dec_2012. Basically my aim is to get the above formula working before I drag it across so that the named ranges get picked up automatically from the headers.

Jan_2012 thru Dec_2012 are dynamic named ranges using INDEX (and not OFFSET as someone mentioned OFFSET is a volatile function).

The above SUMPRODUCT formula is giving me a #REF! error for the (INDIRECT(B9)="x") part. I know that because when I replace it with (Jan_2012="x") it works fine.

I realized while writing this that it may be because the named range in Jan_2012 is not the same size as that of other arrays. [but it is the same size - I've re-confirmed just now]

View 5 Replies View Related







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