Modules & VBA :: How To Get Sum Of Range Of Data

Oct 4, 2013

I am trying to simply find the sum of a range of data...I have tried putting the range into a the formula, and also creating aliases for the cells but it either doesn't work or I keep getting a name error in excel and I just can't seem to get the right code:

The range I am trying to sum is:
Range(Range("B2"), Range("B2").End(xlDown)).Select

And I can find the cell that I want the sum to go into by:
Range("B2").End(xlDown).Offset(1, 0).Select

As I said I have tried a few things but just get this right. Should I be using Value, Formula or FormulaR1C1?

View Replies


ADVERTISEMENT

Modules & VBA :: Naming Range To Export Data To Access Table?

Dec 15, 2014

I am trying to write code in an excel worksheet to try to export excel data to a table in access.

The range in which the data is situated in excel varies. So the range address varies with the data. After a lot of searching I wrote the following code which works for a range which is fixed. The code is the following:

Dim acc As New Access.Application
Range(Range("b22"), Range("b22").End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="ghazla", RefersTo:=Selection
acc.OpenCurrentDatabase "D:PayRollFactoryJasminePayroll.accdb"
acc.DoCmd.TransferSpreadsheet _

[Code] .....

As one can see from the first two lines of code I am trying to first delineate the range and then to name it. The intent is to name the range "ghazla" and so to cater for the fact that the extent of data varies.

The code works with the fixed range ="Sheet2$B140". However what I need to do is to adjust the code so that I can insert "ghazla" as the range name so that this can vary.

View 5 Replies View Related

Modules & VBA :: Subtotal Data Access To Excel - Range Class Failed

Jun 6, 2014

I'm trying to subtotal data in an excel file but I am getting a subtotal method of Range class failed in the red text below. I have been trying to get this to work with no success.

Code:

Public Function SUMMARY()
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
With xlApp
Dim wb As Object

[Code] .....

View 3 Replies View Related

Modules & VBA :: Connect To Excel And Delete Data From A Range On Specific Sheet

Feb 28, 2014

I am trying to connect to excel from Access database. Once I make the connection I want to delete data from a range on a specific sheet. There are 4 columns on the spreadsheet but i wouldn't know how many rows. So for example, A150... but I may not know what the last row is. How would I be able to delete data from a range of columns to the last row?

View 4 Replies View Related

Modules & VBA :: Unable To Export Recordset Data To Multiple Excel Range In Same Sheet

Feb 14, 2015

With below codes I am able to export recordset data to specified excel range if recordset count is 25. But I am unable to export the data greater than 25 to 2 specified range.

View 7 Replies View Related

Forms :: Make A Button To Search Range Of Columns In Data Table With Data Type Yes / No

Apr 15, 2013

what I want to do is make a button to search range of columns in data table with data type Yes/no and display the results if the value is yes

View 9 Replies View Related

Modules & VBA :: Subscript Out Of Range If Run Twice

Sep 4, 2014

The below code exports a table (via a function) to a spreadsheet and saves it in a defined location. the code then opens the file does some work with it then moves it(left the move bit out as it works fine)

so when i run the code it works absolutle fine, table is exported, work is done and file is moved. however if i run the code again it fails, i get the error message out of range. i was originally getting this error when using the .usedrange.copy so i commented this out and now i get it on the next line that tries to work with the file so obviously something is wrong in my logic.

Code:
Private Sub Export2JDE_Click()
Application.Run ("JDE_Export") 'Exports to an xlsx file in the location described in the function.
Dim xlApp As excel.Application
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True

[Code] .....

View 8 Replies View Related

Clear Range Of Data

Jul 12, 2005

Is it possible to clear the cotents from various records but only the values in one column. Like let's say I just want the delete the values in the Price column for a range of about 6000 records. Not the whole records just those price values.

I can't seem to find a way to do this without sitting there and pushing down and backspace over and over again.

thanks,
joëlle

View 1 Replies View Related

Modules & VBA :: Check ID Number Between Range

Oct 23, 2014

I'm trying to create some code that will create a new folder depending on the ID that is currently being added to the database.What happens at the moment is a new ID is generated which in turn is job reference.When this is added to the database a folder is created with a prefix of this ID number and a 20char test specified in a text field by the user.

What I am trying to achieve is this:If the ID = 57...Then a folder is create called 1 - 500 (and ignore if one has already been created, which it should have at ID number 1)...When the ID Number 501 comes along another new folder is create called 501 - 1000 etc etc.The idea is not to have 3000+ folders in just one folder making it look a bit messy and lengthy to look through.

View 3 Replies View Related

Modules & VBA :: How To Do A Join Range Query

Dec 9, 2013

I am currently trying to do a range join query in access (not an expert at all with it) but I realized that it's not easy. It probably needs a VBA code but still not sure how to do it. I basically have a column with number of days e.g

Number of days
18
1
0
56
8
-19
369

Eventually I would like to do a range join query (similar to excel range vlookup) with the following table

NumberofDaysWeeks
0 Same Day
1 1 Week
7 1 Week +
14 2 Week +
21 3 Week +
30 1 Month +
60 2 Month +
90 3 Month +
120 4 Month +
150 5 Month +
180 6 Month +
210 7 Month +
240 8 Month +
270 9 Month +
300 10 Month +
330 11 Month +
360 12 Month +

After joining the two tables with an approximate range (as in excel) the final table should look like below

Number of days Weeks
18 2 Week +
1 1 Week
0 Same Day
56 1 Month +
8 1 Week +
-19
369 12 Month +

Note that value -19 is an error so it should not return anything however i still want to see the value in the final table.

View 4 Replies View Related

Modules & VBA :: Count Of A Variable Range

Jul 30, 2015

1. I have a sample database table in excel where depending on column 2 value >1 is checked and logical results by IF check placed in Column D. The values having "Y" in column D are placed in Columns E:F.

2. Now I want to place count of values meeting the condition on last cell of the filled E:F range.

3. VBA code written by me proceeds fine and places values meeting condition in column E:F

4. I am beginner to VBA and finding difficulty in proper code for placing sum of counts of acceptable values in range F2:F7 in cell F8 ie last value in the array. Presently I have placed the value by In-built Count function in Excel.

File Count on Macro from another table is attached.

View 1 Replies View Related

Modules & VBA :: DLookup To Excel Range

Jul 17, 2014

I am having problems with Dlookup from a table which is linked to Excel.The heading on the fields from Excel have been imported as F1, F2, F3 etc... the code I am using is as follows .....

LOOK = DLookup("F6", "DATABASE_LOOKUP", "F1 = 1338087")

F6 = A date I am looking up.
DATABASE_LOOKUP = table I am looking up.
F1 = 1338087 = The record I am looking for.

View 5 Replies View Related

Modules & VBA :: Finding All Numbers In A Range?

Jul 16, 2014

I need to create a very simple database that would just store records and produce a couple of reports. I have three tables: one with the roster , one has records of the inventory items people from the roster receive and another one contains types of inventory we have. Everything is very simple except for one part. Every time we make a record of an inventory item given to someone, it requires not only employee id and inventory type from the existing tables. It needs us to enter a serial number of an item. This serial number contains a letter and a number.

Looks something like this - M100. Many people receive a consecutive set of inventory items. For example, from M100 to M150. There is no way to have a separate table with all serial numbers because they constantly change. That is why we need to have two text boxes that would allow us to input a range of serial numbers or just one number. Then the program should separate numbers from letters, evaluate the range, create new records of numbers and then put new numbers and a letter back together into one field in the table where we have all inventory records.

I found the following code online that allows me to find numbers within a range, but it only works for numbers.

Dim varRange As Variant
Dim lngLow As Long
Dim lngHigh As Long
Dim lngCounter As Long
DoCmd.Hourglass True

[code]...

I then found a piece of code that is supposed to separate numbers from letters, but I can't find a way to make it work.

Public Function FindNum(strName As String) As String
Dim strTemp As String
Dim i As Integer
For i = 1 To Len(strName)
strTemp = Mid(strName, i, 1)
If (Asc(strTemp) < 91 And Asc(strTemp) > 64) Or (Asc(strTemp) < 128 And Asc(strTemp) > 96) Then
FindNum = Right$(strName, Len(strName) - i)
End If
Next i
End Function

how to alter the code to make it work for my specific situation.

View 6 Replies View Related

Get Specific Info From Range Of Data

Oct 26, 2007

Hi I could do with some advice on how to start the following and if best to use both excel and access to achieve it.

I want to enter a range of data when I receive a bill such as date, supplier, bill amount, description, quoted price, customer job and retail price. Once I enter this I want to be able to do the following,

1.Pick a customer job and date range and get a report for all the details of bills received in relation to that customer in that time so that I can send the customer a list of items they bought in that time period and what each item cost.
2.I want to be able to compare cost prices from different suppliers and print a list of all items which shows who the preferred supplier is for each item based on the cheapest.
3.The quoted price from suppliers should automatically appear when the description and supplier has been entered.
4.There needs to be some sort of warning if the quoted price doesn’t match the bill price
5.I need to be able to get a report which gives the details for any bill which was entered that was not bought from the preferred supplier.

Some advice on pointing me in the right direction to get started is what I need and would be greatly appreciated

Thanks
Adw

View 6 Replies View Related

Modules & VBA :: Subscript Out Of Range In Excel Worksheet

Sep 10, 2013

I have written the following program code:

Dim xlApp As New Excel.Application
Dim xlwrkBk As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim strXLS As String
strXLS = "c:AccessMyfile.xls"
Set xlwrkBk = xlApp.Workbooks.Open(strXLS)

[code]...

The program is stopping at " Set xlSheet = xlwrkBk.Worksheets("singles")"

and I am receiving the following error box:

Runtime error 9

Subscript out of range.

I don't understand this error because I am using the same program code with another Excel file in another module and it works perfectly.

View 6 Replies View Related

Modules & VBA :: Selecting Date Range And Calculate A Sum?

Aug 8, 2013

I want to select a date range from "Production" table where it agrees to the Dept_ID too. And then calculate the summation of the columns "hours", "produced" & "waste" of that particular range selection.

This is my code:

Code:
Option Compare Database
Private Sub cmdCal_Click()
Dim sql As String
Dim rs As Recordset
Dim qdef As DAO.QueryDef
Dim hours, waste, produced As Integer

[code]....

But it returns nothing, When i remove the errorHandler, it says that no records were found.

View 2 Replies View Related

Modules & VBA :: Import To Excel - Add Criteria To Set Range

Mar 18, 2015

I've adapted some code I found which works and allows me to import data from my access table "Device Text" to a specific range in an existing excel worksheet by copying a field "TextEdit" in the recordset. the code is placed in a module behind a command button on an excel worksheet. I have used import to excel because this seems to be less complicated for my needs than exporting from access.

Everything works fine if a single range is set , however I would like to set the range(rng) criteria in the code below to start at a certain cell depending on the value in another field in my access table called "LoopID" this is a number field which is not unique and can be 1,2,3 or 4. I know it wont be evaluated but I've entered the gist in red in my code.

I don't need to import it but I suspect I have to bring LoopID into the recordset somehow to use it,

Code:
'DIM STATEMENTS
Dim strMyPath As String, strDBName As String, strDB As String, strSQL As String
Dim i As Long, n As Long, lFieldCount As Long
Dim rng As Range
'instantiate an ADO object using Dim with the New keyword:

[Code] .....

View 5 Replies View Related

Modules & VBA :: Update Range For Graph Automatically

Mar 17, 2015

I am trying to update the range for the graph automatically and I'm calling this from Access because my data exists in Access. I've attached a sample file.what I am trying to do:

1) click on the button
2) button will update the usedrange in "trending" tab
3) have the graph's data range based on the usedrange.

Code:

Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open "C:Documents and SettingsgjiaDesktopmetric_DEV.xlsx", True, False

[code]...

note: the columns will grow bigger to the right, which is dynamic, so I've used usedrange method, but the code fails on the usedrange line saying the object or method is not being supported...

View 3 Replies View Related

Modules & VBA :: List Box Items And Date Range

Jun 17, 2015

I have a multiselect listbox and two date fields (StartDate & EndDate) in an Access form.I am trying to add records to the Table through the form on a button click.I select multiple items from the list box and the date range between the start date and end date will be equal to the items selected from listbox.For each item selected from the list box I need to add a separate record with a date.So the first record will have List box item selected1 and the start date.Next record will have item 2 from list box and date as dateadd("d",startdate,1)And final record will have last item selected from the listbox and date as enddate.

View 5 Replies View Related

Modules & VBA :: Creating A Filter By Date Range

Oct 2, 2013

I am trying to use VBA to create a filter by date range. the user inputs 2 dates and the database filters all records by dates in between the 2 dates,

Code below

Dim var_CustDate1 As String
Dim var_CustDate2 As String
var_CustDate1 = InputBox("Please enter start date in format DD/MM/YYYY", "Enter Date", Date)
If Not IsDate(var_CustDate1) Then
MsgBox ("not a valid Date")

[Code] ....

I've tried every combination of format for the dates but this is the closest ive got it to work,

if i enter dates 01/09/2013 and 12/09/2013 the filter works for the days in the month but also displays previous years, but if i change the dates to 01/09/2013 and 13/09/2013 it starts displaying all dates for all years in the months September, October, November and December.

View 3 Replies View Related

Modules & VBA :: How To Select Records By Date Range

Nov 30, 2014

I am trying to create a form that will select records by date range. The form contains 2 textboxes, with pop-up calendars to select dates. I managed to come up with this code, however, it's not working. Whenever I run the code, my database just goes blank, as though it's selecting something that is not in the records.

Code:
Private Sub Command16_Click()
Dim Task As String
Dim startDate As Date
Dim endDate As Date
startDate = Me.Text12
endDate = Me.Text14

Task = "SELECT * FROM Final WHERE Final.Timestamp BETWEEN #" & startDate & "# AND #" & endDate & "#;"
Me.RecordSource = Task
End Sub

How does one actually do the date range search? Could it be because my timestamp actually has both date and time, that's why the date search is not working?

View 5 Replies View Related

Modules & VBA :: Date Range Option On Form

Jul 16, 2015

I have a form that has several drop down menus on it. I use the form to filter the database to only the options that are put into the drop down windows. I have it set up so that every window does not need to be filled in for the filter to work. Now I am trying to figure out how to put the option of a date range on my form as well. The code that I am using to make everything up to the date range work is.

Code:
Private Sub Search_Button_Click()
DoCmd.Close acForm, "Admin_CompletedPartSearch"
str_Form = "Admin_CompletedPartSearch"
str_Filter = "(1=1)"

[Code] ....

I can't figure out what I would need to do to make a date range also fit into this code but not to be required.

View 1 Replies View Related

Modules & VBA :: Statement For A Range Between To Combo Boxes

Jun 2, 2014

I have a form with textboxes and comboboxes and a Button,when button is clicked, a new query is made, with criteria based on boxes on form.For example this one :

Quote: If Not IsNull(Me.cmbType) Then Where = Where & " AND [TypeID] = " & Me.cmbType

What would be the statement for a range between to combo boxes.I have 2 comboboxes (cmbBox1 and cmbbox2), show only records equal and between the ones selected in cmbBox1 and 2.

View 9 Replies View Related

Modules & VBA :: How To Properly Set Range In Transfer Spreadsheet

Sep 18, 2014

DoCmd.TransferSpreadsheet Range parameter.

I want to import from an xls-File just the second page, titled "Harte". How do tell this the compiler?

Code is:

DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel8, "Harte", file, True, "Harte"

View 1 Replies View Related

Charts - Controlling Data Range With Code

Jan 30, 2008

I have a nice chart that hasd done what I wanted it too.

Now I want to make the amount of X-AXIS data variable. Typically this would be 64 points. If you look at the datasheet, I can manually set the number of points by making sure the row selector is "raised".

Now that's say there is only 16 points of data to control. I can plot that those points but the chart is still 64 points wide with no data for points 17-64.

How can I, through code, prevent points 17-64 from plotting and thereby expand the graph horizontally larger and not display those null points?

I have tried a number of things including:
objDataSheet.Row(17).Delete
Graph_Data.Range("A1:A16:)
etc...

Nothing I have tried has worked. Is what I need to do possible?

Thanks much.

View 2 Replies View Related

BETWEEN For Text Data Type Date Range

Jan 10, 2005

I am creating an ASP page that uses a database with a field labeled 'Date' of data type Text.

I would like the records within a date range.

I tried using the following query:

"SELECT * FROM Project WHERE Date BETWEEN ' " + strBeginDate + " ' AND ' " + strEndDate + " ' "

I was partially successful.

The database contains data from 1/1/03 to 12/31/04.

When the following range is entered: 04/10/03 - 04/21/03, the results returned are 04/10/03 - 04/21/03 AND 04/10/04 - 04/20/04.

Any suggestions on how to approach this problem?

Thanks

View 3 Replies View Related







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