I'm doing a function to comprobate that a cell value has 11 digits. I'm not use only a validation because the the cell value can start with a 0. So I make this function
'This function is to get all the characters from a cell Function ValidaSeguro(SS As String) As Boolean Dim strArray() As String Dim lLoop As Long, lCount As Long Dim Respuesta As Integer lCount = Len(SS) If lCount <> 11 Then ValidaSeguro = False Respuesta = MsgBox("Don't have 11 digits") Exit Function End If Redim strArray(lCount - 1) For lLoop = 0 To lCount - 1.........................
I have a spreadsheet that has data in columns A through AE. I have built a VBA that deletes all columns except 2 (columns C & AF), and brings them over to columns A & B.
Column C contains a 10 digit number and column AF contains text similiar to "ASSIGNED ON 10 CALLS BOLDI". My VBA deletes all unneeded columns, but I am having trouble getting it to do 2 additional functions. I want it to delete the verbiage of "Assigned ON" in the cells under column AF, and delete the last number of the account number under column C, so that the account number is only 9 digits long. Here is my VBA:
I have tried multiple forms of LEFT, RIGHT, MID, etc. Date & Month are always three characters, but the date ("12" in this example) can vary between 1 or 2 characters.
I am not sure if this is doable in VB or if there is an excel function to do this but I am using a rather large worksheet that is shared amongst my staff. I would like to have the sheet clear any filters that have been used by one member and for the sheet to save with the cursor in the home cell (A1). This way the sheet is ready for the next user. Can this be done with VB?
I'm coping and pasting data (html) into a worksheet. When I try to format some of the columns as accounting$, number, ect. They won't format. It looks as if there are spaces before and after the data. So I tried the trim and clean function but it doesn't work, so I guess the blank "spaces" are not really spaces.
It gets better...
When I do the same exact copy and paste (as html) on another persons computer, they are able to format just fine, and the "spaces" are removed automatically.
Why is this working on one computer but not the other? Is it a setting that my computer has enabled or disabled? If so, what is it?
Assume a cell -- say A1 -- has a long formula in it. If I select A1, press F2 to "Enter" the cell, then I have a blinking 'l' indicating the cursor/pointer position WITHIN the cell.
Is there any way to control the position of the blinking 'l' (or whatever it is called)? For instance, in a long formula, I would like to write a macro which could transport the blinking 'l' to midway into the formula string.
Alternatively, can I make a partial selection WITHIN a cell and run a macro on it. For instance, if cell B1 has a heading "Dec 2007" and I highlight just the "Dec" portion of the string, I would like to execute a macro to color it red. I have a simple macro that can do it to the entire cell, but not to only part of the cell contents. Is there any way for VBA to be active when I am WITHIN a cell.
Sub Font_Red() 'will add red color to ActiveCell font Selection.Font.ColorIndex = 3 End Sub
This is my first use of the forum as I only joined yesterday after a recommendation from another colleague.
I am attempting to write a macro to clear the contents of cells in a range that have conditional formatting. Below is the formula I have used...
Sub clr() Dim r As Range For Each r In Range("09:050") If InStr(r.Interior.ColorIndex, "40") Then r.ClearContents Next r End Sub
While the formula runs without error, it does not clear the contents, although I read on another thread on this forum that you cannot clear contents of cells that are conditionally formatted.
Alternatively, if there is a more efficient way to clear cell contents (without using a formula in the cell itself),
On my worksheet, i want to execute a macro to calculate and display some informations when the mouse is positioned over certains cells. I look around but did not found how to do it.
I want the information to be displayed above that cell and disapeared when mouse pointer moved away.
I'm wanting to filter a set of data by inputting in to a cell. And it works perfectly...
VB: Private Sub Worksheet_Change(ByVal Target As Range) If (Intersect(Target, Range("B4")) Is Nothing) _ Then Exit Sub End If Cells.AutoFilter Field:=2, Criteria1:="=" & Range("B4") End Sub
The only thing is I now need is for the code to clear the filter if the cell (B4) is blank. It currently filters out all the data if the cell is blank.
I would like to write the code or create a macro that will execute when the value of a range of cells is greater than null. The macro or code that I would like to execute will UNHIDE a group of consecutive rows.
I need to be able to hide and unhide a given set of rows based on the value in a particular cell. My current code allows me to successfully do this, ONLY, when I select the cell being 'watched' for changes and press enter. It does not execute the code automatically.
The cell is changed by a set of filters that modifies the data. The watched cell is then a summation of the filter modified cells. If the filters change to all "0" or "-" then my 'watched' cell sum becomes "0" and thus should execute the code automatically.
Current Code:
Code: Private Sub Worksheet_Change(ByVal Target As Range) ActiveSheet.Outline.ShowLevels RowLevels:=3 If Range("I62").Value = "0" Then Rows("63:87").Hidden = True End If End Sub
So, right now if I use the filter and the cells change then the sum in I62 becomes "0", I have to manually select cell I62 and press enter and which point the above code executes exactly as I intend.
I need the execution part to be automatic and not have to manual click into cell I62.
VB: Sub autofill() Range("A1").Select Selection.autofill Destination:=Range("A1:A1048576 "), Type:=xlFillDefault End Sub
but i need to select first cell in every 20th column and then execute autofill till the last row that excel provides. I can only do this manually but I have for now 125 columns to fill or to write some monstrous code. Unfortunately I do not have the knowledge to do this in a smart way and I guess there is an elegant way to solve this problem.
I have to run a report each morning and in once cell I need to pull in the contents of another cell from another worksheet. I'd rather not have to open the additional file each morning to copy and paste special the values so I'd like to add to my current macro to pull this data in automatically. I have to do this for two different reports/portfolios and the data I am pulling in for each portfolio is located in the same exel file but under two different tab names, the portfolio names 2010 and 2045.
Deliverables The spreadsheet I am pulling data in from is located here: K:Risk OversightMarket RiskTracking ErrorBARRA and the file name is: Daily Barra Tracking Error.xls
Tab name would be 2010 for the 2010 portfolio or 2045 for the 2045 portfolio The vlookup will be from "A32:B2500" and I would like to incorpoprate an IFERROR function that returns "" in the event of an error. Column "A" are dates and column "B" is the data I need to pull in.
Receivables I am pulling the data into cell "J23" of a summary report (sheet 2) and would like the vlookup to read something like this:
IFERROR(VLOOKUP("K1"Active.Workbook.Sheets2,[K:Risk OversightMarket RiskTracking ErrorBARRA"&"Daily Barra Tracking Error.xls"(Sheets)]."2010""A32:B2500",2,0),"")
This should return a blank cell if the date cannot be found in the data spreadsheet and return the correct data for teh correct date being referenced in my summary sheet.
how to do the bracketed parts for pulling in the right spreadsheet and tab.
I'm using Excel 2003 and I'm trying to make my LINEST function and the source cells for a scatter graph use the cell range specified in another cell in the document. I figured out that it was simple to do the following:
But I can't figure out how to do this in a larger function. I've tried a few things but none of them work. Here is an example where I want it to do a LINEST with y values in cells Ja - Jb and x values in cells Ia - Ib (where a and b are integers specified in cells I250 and J250 respectively):
I have created a List in excel of various tasks. (See attached example.) Each row contains one cell with a function which equals the cell above it and to the right. So the function for cell C3 would be D2. The only importance is that the cell mirrored is always the cell one above and to the right. However, now I would like to be able to rearrange this List, but the “one up and to the right” function will now be all over the place.
Is someone aware of a function which will target a relative location instead of an exact cell?
I have been looking around have this much code from this site, modified. What I am trying to do is calculate numbers by a position with cells D through K having numeric values. I have 'hardcoded' the cells (D2, E2, etc in the code below), but in reality I only want the current row (so if the formula is on the 2nd row, I want D2, if it is on the 3rd row, I want D3).
My problem is obviously the formula isn't working because I am not correctly tying back to the spreadsheet (Positioncalc.xls). When I put the formula in the spreadsheet it works, but in my script I get 0 everytime.
My Script:
Function Position(rCell As Range, Optional RightPosition As Boolean) Dim vResult
Select Case rCell.Text Case "QB" vResult = (2*D2) + (2*E2) + (2*F2) + (4*G2) + (2*H2) + (1*I2) + (4*J2) + (3*K2) Case Else vResult = "Invalid Position" End Select
If RightPosition = True Then Position = vResult Else Position = "Position not valid" End If
End Function
So, when I put =Position(A2,True) I expect to see the formula results of those cells calculated based on the position (QB, HB, etc with their unique formulas).
My next challenge after this is to highlight certain cells based on the Position. So if A2 = QB, I want cell D2 boldface and Red, etc. I have seen some scripts on colors and such here, so I might be able to figure it out.
On sheet 1 I have a list of 1000 firstnames On sheet 2 I have a list of 1000 emails,
I need a function that states If a cell in the email column contains a string or value from the names column, it will result in a true statement so that I can separate out the emails that have these peoples first names.
I am trying to return a TRUE or FALSE based on a date in a cell.
for example:
if cell A1 = 07/11/2009
I want A2 to show TRUE or FALSE if A1 is 14 days or more behind todays date.
I have tried stuff like:
=IF(A1=TODAY()-14,"True","False")
but it just always says false. EDIT: I have just noticed that if I change the date in A1 to exactly 14 days behind todays, it returns TRUE. So, it does work. Do I need to add a GREATER THAN in there?