This is the code that Recorder proffers to simply take a Range of 3 Cells and make Type Font Black/Bold and to place Thin Borders inside the range and Thick Borders aroung the range.
ActiveCell.Offset(0, -2).Range("A1:C1").Select
Selection.Font.ColorIndex = 1
Selection.Font.Bold = True
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
There are two columns with data. These are Assessed Object and Value on Day X.
I would like to be able to have all columns on the master sheet filled out.
This means i would need the data from sheet1,sheet2 and sheet3. First off, how would I be able to get the individual objects data to match up on the master sheet without having to look for and select that one particular object? I know there must be a more effecient way where i can pick all objects with their corresponding values and excel sorts them out appropriately. How would I do that???
Due to the fact that objects may be assessed one day and not the next there will be lots of "gaps" in the data. I would like to put a zero value in a blank cell when that happens. What I mean by this is on Day 3 some Assesed objects will not be the same as those on Day 1 (or Day 2) while some will be the same but will have a different Value on that Day.
For example, car is an object that has been assessed all three days so there are no problems there. But farm has only been assessed on Day 2so I would like an automatic zero value for the days where it has not been assessed. How do i do this???
Also, for objects that have appeared for the first time (such as bread on Day 3), I need to have the previous day values at zero. How would i go about getting excel to automatically do that???
Normally I would copy and paste the data into the master sheet but im dealing with thousands of objects so thats out of the question. Thats why I would like to learn to compile this data more efficiently.
Attached is an example excel file with the 3 spreadsheets and master sheet to illustrate what im trying to accomplish.
way the code below can be made more efficient? Basically, I drop down a combobox, and based on the value i select, it populates a lot of textboxes etc based on the listindex.....
Private Sub ComboBox3_Click() On Error Resume Next With Me.ComboBox3 If .ListIndex = -1 Then Exit Sub Label23.Caption = Sheets("overview").Cells(.ListIndex + 2, "c").Value Label24.Caption = Sheets("overview").Cells(.ListIndex + 2, "b").Value Label38.Caption = Sheets("overview").Cells(.ListIndex + 2, "d").Value TextBox1.Text = Sheets("overview").Cells(.ListIndex + 2, "e").Value TextBox2.Text = Sheets("overview").Cells(.ListIndex + 2, "f").Value TextBox3.Text = Sheets("overview").Cells(.ListIndex + 2, "g").Value
It takes about 10 seconds every time i choose another project
I like to use the combo box (Active X control). where I need to provide the range/List in the properties. While inputing the value in properties it is disappeared.
I need to learn the syntax and all options I can use with the Selection function - where can I find that info? I can't find anything in in Visual Basic Help (I find microsoft help is generally totally useless).
For example, in the code below, what are all the options I can use after "Selection. " (ie .Copy, .End, .Select) and what do I use if I want to select a certain number of cells to the left or to the right or up or down?
Sub Fill() Selection.Copy Destination:=Range(Selection, Selection.End(xlDown).Offset(-1)) Selection.End(xlDown).Select End Sub
I'm just noticing now that the "(xlDown)" is X L, not X 1, which I thought might make sense to say "1 time Down". What does the "xl" stand for?
How do you set the range with whats below? Right now its looking at 4,2 only and if extend to look all the way to 19,2 it will just copy the whole screen. I need it to look at 4,2 and then move to 5,2 and then so on once it has copied all that information to the sheet ...
i would like to set a criteria bewteen a ranges. eg If A1 >0 but <100 then .3, Else If A1 >99 but <200 then .6, Else .9. How do i write this in the cell?
This should be easy ... can't figure it out. If I want a formula that wants to perform an action (NPV, but I don't think that matters) on the cell directly above and the next "X" (say 20 cells/years of cash flow) to the right of it, how can I set it up so that I can copy the formula across as well as change "X".
(Obviously, it's easy to select a 20 cell range and copy it across ... but what if I want the length of the range to by dynamic (ie I want to switch to a 40 year NPV instead of a 20 year)?)
I am trying to set an Array to prompt user with a series of questions and input answers into a specific row. However, I want to skip over certain columns and leave those blank. How would I modify my code to do this?
Code:
Private Sub CommandButton2_Click() Dim ArrQues() As Variant Dim ArrInput(2) As Variant Dim lngLstRow As Long Dim strPNfromSales As String ArrQues = Array("Enter the Part Number.", _ "Quantity Being Returned?", _ "What is the Reason for Rejection?") For b = LBound(ArrQues) To UBound
[Code]...
I want the first two questions to be input into Column B & C, but then the third question to be input into column I.
When I'm using the Macro recorder or even after I've completed a sequence is there a way to change the range so it code always covers the complete range of the data?
I have a general list from which a chart is created. Column one contains a date series. There are a fixed number of dates in this series (approx 50 or so).
I would like to select a start date and an end date from this list and have the chart display the data from that range.
Typically I would simply create a new list and build the chart from the list, but I'm kind of hoping that I could do it from a single source rather than make mulitple lists.
I am attempting to set a variable as a range of data that sits on a non-activated worksheet. However, I am getting a runtime error of 13 (data mismatch).
Is there something in my code that may be incorrect? Here is my code:
Dim rRange As Range Dim sRange As String Dim tblName As String
On Error Resume Next Set sT = Sheets("Report") On Error GoTo 0 On Error GoTo nendR If Not sT Is Nothing Then
[Code] ........
I get a Subscript out of range at Set cT = Sheets("RGA by Customer") line.
It baffles me that when neither sheet exists and the first part runs there is no problem, but when it gets the the above mentioned line I get this error. Same exact code, just a different sheet name.
Again, when the sheet exists there is no problem. Only when I click on Sheet1 (or start up the file) and this sheet doesn't exist do I get the error.
Im trying to set a range using a named range and dont know the best way to do this. so far ive got
Set rDataRange = Range(Offset("datastart",1, 0) & ":" & Offset("datastart",LastRow, 0))
datastart is the named range in the sheet and im trying to make a new range that starts 1 row below where datastart is and end where lastrow is. not sure where i messed up on this but i get errors when i try to run this
I'm having trouble setting the Range "UtilizationRange" using a variable, "CurrentRange" to store that range. I get the error "Run-Time error 1004: Method 'Range' of object'_Global' failed".The rest of my code works when I set the utilization range using the actual range for my purposes, but the problem is the range will change each month and I don't want to change it manually each time. There's a cell in the excel sheet this refers to (AG3) that holds the range value, which in this case is [N7:N75], and I would just like to return that value to the variable "CurrentRange" and set UtilizationRange equal to that.
The value is returned to CurrentRange, but it's the last line that's giving me the problem.
Sub RangeTest()Dim UtilizationRange As Range, Cell As RangeDim CurrentRange As String CurrentRange = Range("AG3").Value MsgBox (CurrentRange) 'This returns the value [N7:N75], which is what I want Set UtilizationRange = Range("CurrentRange")End Sub
I have a certain number of accounts for opening and close dates. What I wish to acheive is to fill a Range of date from the opening to the closing (or up to 200606 YYYY-MM) in another spreadsheet with the account number corresponding to that date next to it.
The VBA I have right now manages to create the list of accounts but up till 2006. It isnt taking into consideration the closing dates of accounts.
So For example What I want is to set up inside of the loop that to continue to do the loop until it reaches the closing date by YYYY-MM so if the clossing date is 200504 I will have data filled up to that date, and if the closing date is "" then fill the dates up til 200606. Ive tried out a number of ways of inserting the if statement but apparently the string create a problem.
Here is my current VBA and a Sample Sheet of what it looks like....
i have compiled a multipage using some borrowed code and some code i have written myself. most of it works, but i have a problem populating listbox2.the error is in Private subCmbFindAllJobNo_Click(). i have put h1 tags around the line of code which shows the error when i debug. this code works ok as a stand alone, so i suspect i have done something wrong in the userform initialise.
Option Explicit Dim rng As Range Const FirstRow As Long = 2 Dim r As Long Dim ans As Variant Dim MyArray(100, 4)
I am creating a range of numbers from 1 to 2000 with increments of 0.5. Then I have to subtract certain range, for example, 100 to 350. So, the result should display, 1 to 95.5 and 350.5 to 2000.
I recently set up some functions based on Chip Pearson's tutorial for referencing worksheets from Formulas. (http://www.cpearson.com/excel/sheetref.htm)
The problem I'm now having is that I can't use VBA to set these functions in place; it returns a syntax error.
For example, I want I37 on most sheets to have the same formula. So I have the following:
Trying to write a macro to transcribe data from columns in Sheet1 to Rows in Sheet2. Assuming there is a blank between each record. I get an error on the "Set Rng1....." line.
I've got two sheet's in a workbook. The first contains data and is setup with dates in column A, day of the week in column B, and values going across by day in column's C through H. As an example it looks as follows:
Im having slow performance reading a CSV file into 34000 sheet named ranges. Currently it takes about 8 minutes to read 34,000 records. After stepping through the code Ive realized there are two bottle necks.
1)finding which sheet that the range name resides see getRangeAddress() and
2) actually setting the value to the named range i.e. Range(ra) = dprecord(1)
The CSV file looks like this: <range name>,<data value> e.g. DPA_1001,99090
Performanace actually seem to slow as the macro runs.
Public Sub readDatapoints() 'Macro readDataPoints 'This macro will read in the a comma seperated value (CSV) file of datapoints.
Dim sFile As String Dim currentLine As String Dim delimit As String Dim counter As Integer Dim ra As String Dim fs As Object Dim ts As Object Dim dprecord Dim oldStatusBar As Boolean delimit = ","
I'm trying to find the last row on a sheet and then set the next cell, in column A to a certain value. It fails with Method 'Range' of object '_Worksheet' failed.
'activate the male page sMalePicks.Activate
'add to last row of male baggage lastRow = sMalePicks.Cells.Find(What:="*", _ SearchDirection:=xlPrevious, _ SearchOrder:=xlByRows).Row