If a cell in some parts of the worksheet (SSMa,SSDi,SSWo,SSDo,SSVr,SSZa,SSZo in the code) are selected the input (4 digits) should be converted into time (00:00). Cells in some other parts (Util,Assis) require 6 digits and should be converted into time (00:00:00).
I had the code working in seperate worksheets but combined (as is shown in code bellow) only part of it works.
Only the input entered into the 4 digit part (SSMa,SSDi,SSWo,SSDo,SSVr,SSZa,SSZo) is converted correctly.
The input in the other parts (Util,Assis) is not converted (so when 800 is entered I do not get 00:08:00 but I get the hour equivalent of 8 days (19200:00:00) and logically the message from the EndMacro "You did not enter a valid time". The cell formats are correct [u]:mm and [u]:mm:ss.
To me it looks like it does not jump to the 6 digits part when need but I can't figure why.
Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim TimeStr As String
On Error GoTo EndMacro
If Application.Intersect(Target, Range("SSMa,SSDi,SSWo,SSDo,SSVr,SSZa,SSZo,Util,Assis")) Is Nothing Then Exit Sub End If If Target.Cells.Count > 1 Then..........................
Just starting to learn VBA. I have the 2 following codes.Can they be combined into 1 code.I have 2 buttons one say hide rows and the other button says unhide rows....can 1 button be used and when the rows are visible the button says hide rows and when the rows are hidden the button says unhide rows
Sub hiderows() ThisWorkbook.Sheets("sheet1").Rows("3:12").Hidden = True End Sub Sub unhiderows() ThisWorkbook.Sheets("sheet1").Rows("3:12").Hidden = False End Sub
I'm trying to create a macro to merge multiple rows into one cell and display in a new worksheet.
This seems really simple but I've tried to re-work some other examples I've found online but none seem to do exactly what I need. I'm also pretty new to VBA , so it's highly possible i've missed something.
I need to display each set of Notes for each DonorNo in one row - with each note separated by a space.
I've attached a sample of the data and what I need for the output. In the actually file I have around 70,000 records so the prospect manually merging the rows is horrifying.
I am attempting to write a small code for the following scenario.I have a workbook with worksheets GP1, GP2, GP3 etc & a template page as the last tab.
All the worksheets column names are same but have different data.Last worksheet is the template for all of them. How do I create a command button in template page... upon clicking the button,
it should create a tab just before the template worksheet incrementing previous tab GP3 +1-> GP4. GP4 should be a copy of the template page along with all the vb codes associated with the template page.So tabs looks like=> GP1, GP2, GP3, GP4, template
I have below code, but does not work correctly. The problem is when it's run in main worksheet, it doesnt match the correct workbook in every worksheet and it only generates the data in first workbook for all worksheets. It seems that it lacks something link between workbook in main worksheet and workbook in others.
Sub HzWb() Dim bt As Range, r As Long, c As Long r = 1 c = 8
I'm trying to write a macro that selects file A, copy some particular columns in file A, copy them into a new workbook, then repeat the process for file B, and copy and paste the columns into the same working workbook. Does anyone have any suggestions on using any one of the workbook, worksheet functions to do so?
I have set up a control sheet that gathers information over the current week, eg: amount of deliveries and total cost. On the control sheet it gives the amount of deliveries and total like at say A10 and B10, on this same page I have a 52 week colomn that needs to gather this information. Now the problem is a new delivery plan is used each week but the control sheet stays the same, how can I get the data from A10 and B10 to copy to the different lines in the 52 week sheet. Have attached the workbook for reference.
I have several workbooks (called Cons_age0, Cons_age3, Cons_age6 and Cons_age12) that I would like to combine into one workbook called Cons. Each of the previous workbooks should now be a worksheet within Cons by their name.
I have about 600 patients' charts, which I audit every 3-6 months. I have created a macro which imports each patient's workbook into a single workbook (one worksheet per patient). Now I'm trying to create a macro which will import each patient's most recent audit results onto one worksheet. Here's how the results are organized:
2/1/2010 Audit 3/1/2010 Audit 4/1/2010 Audit Y N N/A Y N N/A Y N N/A x x x x x x
...etc., with each audit taking up 3 columns and 32 rows. My code, however, is not working,
I'm trying to consolidate data from different worksheets that has the worksheet name consisting of "Pg*" into a summary sheet. The problem is it does not loop through every sheet and only extracts data from the active sheet.
Code: For Each ws In ThisWorkbook.Worksheets If ws.Name Like "Pg*" Then Set CopyRng = ws.Range("A2:G68")
I am trying to do is have a worksheet that gets its information from other worksheets within the same workbook. Some of the worksheets that it gets its data from are web queries, and as such change on occasion (columns stay the same but rows get inserted or deleted as data on the web page that it is importing changes). Also due to this being an import I can not change directly the format that comes onto the sheets (ig split into different columns etc). Much easier described within the example as I am not sure of the words to best describe the end result I am looking for. A copy of a smaller version of what I am doing is attached
I'm trying to convert various codes from one column of an excel spreadsheet into different codes in another column. I was able to accomplish this with "If" statements, however I'm only able to string together seven of these statements in one command. Is there a better way to add formulas for more than seven conversions? Below is a copy of what I've done so far with the seven converts:
I have a set of related variables that are split over multiple worksheets, and I need to be able to take specific information, duplicate certain values and produce an output sheet for use in a separate piece of software.
The variables are: Position Number (Sheet 1) Position Title (Sheets 1 and 2) Position Requirement (Sheet 2) Requirement Importance (Sheet 2)
The output sheet requires a list of all the requirements for each position number, which means the position number itself needs duplicating (in new rows) X number of times, where X is the number of requirements assigned. The appropriate requirements are then to be pasted in next to each position number (and the requirements can be found by comparing position number to title, and from title to requirements).
Normally, I’d be able to do this using lookups and so forth, but my problem arises when I have multiple position numbers with the same related title (in the attached example, there are three plumbers with unique position numbers). I can’t figure out how to say to Excel “a plumber has five requirements, and there are three plumbers, so duplicate each position number for each plumber five times, then insert the appropriate qualifications (and their associated importance values) next to the position numbers”.
I've got a worksheet with five columns of data. One of the columns contains country codes. I have a list of countries that the codes relate to. I would like a new column in the worksheet that contains the country name. I'm not sure if this is possible, but it seem that most things are with VBA! The countries and their codes are on 'Sheet2' I relalise I might have to do some boring re-ordering of the data on 'Sheet2'
i have some existing code which is trigerred when anything is input into column c. The code then adds various information in another three columns. One of which pastes a vlookup formulae, and i would like this forumlae pasted into the column c cell which i initialy edited, in order to remove the requirement for one additional column.
The existing code i have is:
Code: Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim MyText As String MyText = Environ("username") If Target.Cells.Column = 3 Then With Target If .Value "" Then .Offset(0, 2).Formula = "=VLOOKUP(D:D,'P:TAOffshoreTAOffshoreTreasuryRecsGeneralCommit ID''s for control Sheet - Do not move or delete[commit ids - DO NOT DELETE OR MOVE.xls]Sheet1'!$A$1:$B$65536,2,0)"
I have tried changing the offset to (0,0) or changing the offset to 'target = ', which does add in the vlookup but then the macro debugs at the 'If .Value "" Then' code?
I am fairly new to macros and have trouble with VBA. I have a file with multiple worksheets. Each worksheet contains the name of a specific location in cell A8. I want this name in cell A8 to be the name on the worksheet tab for each worksheet in my file but do not know how to accomplish this. Is that even possible?
In cell A1, I have the month number (eg, 1, 2, 3,). The month number reflects current month and will automatically change with every month. For example, right now it’s 6, next month it will automatically change to 7. Each two columns in Range A10:X20 represents the data from January to December. I want to use a worksheet event to change the background of the current month two columns in the range to yellow color and the two columns in the range will be visible when I activate this sheet.
looking to only allow a check ("x") in a column for a reconcile - type worksheet. Am I close?
Private Sub Worksheet_Change(ByVal Target As Range) 'Data protection. Only allow "x" in the "cleared" column. If anything else is entered, a message box informs the user 'and the cell contents are cleared. Dim val As Variant Dim msg As String If ActiveCell.Value "x" Then msg = "You can only enter an X in the cleared column." ActiveCell.ClearContents End If End Sub
Is there a way to either change this so that it lets me to select the whole area or a way to make a macro to do what this does to one cell?
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Range("M13:IR458")) Is Nothing Then Select Case Target.Value Case "1" Target.Font.ColorIndex = 20 Target.Interior.ColorIndex = 10 Case "Good" Target.Font.ColorIndex = 2 Target.Interior.ColorIndex = 35 Case "Stable" Target.Font.ColorIndex = 2 Target.Interior.ColorIndex = 27......................