My worksheet with macros gets messed up when a user selects either multiple cells from column F or selects multiple cells in any one row (but only if column F is included) in the range C17:O116 and hits "delete". I will either do an exit sub, an application.redo, or something similar so that this doesn't happen, but I don't know how to write the code to trigger these events. So I need a way to determine "if the user selects multiple cells in column F and hits delete" or "if a user selects multiple cells in any row from 17 to 116 that includes the cell in row F, and hits "delete.""
Set Rng = Range("F17:F116") Set rng2 = Range("K17:K116") Set Rng3 = Range("L17:L116")
I'm struggling with getting my Excel worksheet to fit nicely on the pg for printing to .pdf. I could tinker with column widths manually to work this out for a printed report. But I need to print a couple hundred reports with varying column widths, so I need a vba solution.
The context is that I'm using vba to process two sets of interlinked data on a worksheet. I only want to print one set of data, and keep the second set out of the print view. To do this, I'm keeping the first set of data in columns 1 to 10 and the second set of data in columsn 21 to 30. I set the print range to only include columns 1 to 10.
This works fine for keeping the second set of data off the printed pg. The problem is that there is always a gap between the end of column 10 and the maximum width of the printed pg. Given the formatting of the report, this doesn't look very good.
I know that page setup offers the "fit to" option. This would work if I wanted to fit everything on the worksheet on the pg, but I don't. I just want to fit columns 1 to 10 to the pg. Is there a way to do this, allowing for varying widths in columns 1 to 10? Is there a way to do it via vba?
I'm trying to come up with a histogram chart that adjusts Bin Size based on user input. I've come up with the formulas for Bins and Frequency, but am struggling when it comes to charting the data to dynamically update when the user changes Bin Size. How to make the x-axis dynamically adjust with the number of Bins.
Is it possible to have an "if then" statement that would send the user to another page in the workbook? For instance..... =IF(D12="Mobile","Sheet2!","Sheet3!"). I know this does not work but is there another function that would do it? I am very new to vba and am sure it is easy there but I do not have a good handle on it yet.
Indicate that a user-defined function can only be based upon the calculations that can be placed in a single cell. If you have too many calculations to put them into a single cell, e.g., an entire page of calculations based upon a few starting parameters that eventually yield a single value, then how do you reuse this entire page of calculations?
Is there another Excel mechanism that allows an entire page of calculations to used as a stored procedure?
I have a userform1 with multipage 1 which has 5 pages. Is it possible to select page 1 from a label on page 5. I have the following code assigned to label 18 on Page 5 but I can't get to Page 1. In fact, the code does absolutely nothing.
Private Sub ComboBox1_Change() 'was A, now N DataReport.ComboBox2.Clear If Data5m.FilterMode = True Then: Data5m.ShowAllData Data5m.Range("A1").AutoFilter field:=14, Criteria1:="=" & DataReport.ComboBox1.Value Call FillCombobox(Data5m.Range("X2", Data5m.Cells(Rows.Count, "X").End(xlUp)).SpecialCells(xlCellTypeVisible), DataReport.ComboBox2)
Is it possible to use the resize function in Excel VB to select all rows that are between 2 page breaks.
I have a worksheet with several pages of data. Each page is separated by a page break at the top and bottom of the range, each page can consist of any number of rows from 20 to 50. I need to look for a specific criteria in column A in each of these pages. If the criteria is met, then I need to delete that page.
For example, if the cell where the criteria is met is A50, in page 2, and the page break above this is at row 45, and the one below is at row 55, then delete rows 45 to 55
I have the code that finds the criteria in column A. I tried to use the offset and resize functions but as there isnt always a consistent number of rows involved this didnt work
If this isnt possible, can you refer to page numbers in excel, so if the criteria is found in pages 4, 7 and 10 of the data then these pages are deleted?
I have a sheet that already has page breaks set at specific intervals to ensure the data is displayed in a certain way on print, I can only have whole pages. The variable is how many pages are printed on each project, which can be anything between 1 and 20 or more. I have a few columns that contain line numbers, and formulae down the entire length of the sheet, so a basic last populated cell search won't work, but the column I'd like to focus on is Col F, which only has blank/empty cells below the last used one in use. Is it possible to have a BeforePrint code find the last populated cell in Col F and simply capture which print page number it is in, and set that as the number of pages to print?
So in summary, I'd like to be able to just hit Print, and the code will automatically set the number of pages to print based on which page contains the last populated cell in Col F.
I'm using the select sheets to print code from: http://j- walk.com/ss/excel/tips/tip48.htm. I need to add in another option to select whether to print the page as horizontal or landscape. I've been able to add the checkbox, but am having a hard time with the loop to process correctly. I also have the landscape changing code as well. Here is my Option Explicit Sub SelectSheets() Dim i As Integer Dim TopPos As Integer Dim TopPos1 As Integer Dim SheetCount As Integer Dim PrintDlg As DialogSheet Dim CurrentSheet As Worksheet Dim cb As CheckBox Application.ScreenUpdating = False If ActiveWorkbook.ProtectStructure Then MsgBox "Workbook is protected.", vbCritical Exit Sub End If Set CurrentSheet = ActiveSheet............
I have a file for which I wish only selected pages to be printed, so I have disabled the print function in the ThisWorkbook module. Instead, the user chooses from a menu of available sheets to print, via a user form, and then requests the print.
I've got most of this sussed in my mind, but the users need the option of which printer to use (loads of networked printers available and the choice will depend upon monochrome for draft print or full colour for final print), so I want to be able to call up the printer dialog box using
I want all the options on the dialog box disabled, except for the choice of printer as clicking OK after choosing the printer adds the active sheet to the list of items to print.
I have the following code that is going to trigger an export macro and an import macro allowing the user to upgrade the version of their report;
x = MsgBox("Is the file you wish to export from open?" & vbCrLf & vbCrLf & "If it is click yes" & vbCrLf & "If its not click No" _ & vbCrLf & "If you need to abort the macro click cancel", vbYesNoCancel)
Select Case x Case 6 MsgBox "Please use the Windows menu in Excel to ensure that the file" _ & "you wish to export from is the ActiveWorkbook!", vbInformation ' Missing step If ActiveWorkbook.Name = ThisWorkbook.Name Then Exit Sub ExpWb = ActiveWorkbook.Name Case 7 On Error GoTo Handler .......................End Select
Problem is, I have a missing step within Case 6 which allows the user to ensure that the file they are exporting from is the ActiveWorkbook.
I want to force a user to select a value from a Combobox that I set up in a newly created worksheet from inside a macro - while the macro is still running. I have the code to create a new worksheet, size it accordingly, add a Combobox control, assign a range of values for the drop-down list, but do not know how to suspend the macro and force the user to make a selection from this Combobox before continuing. Not even sure if this can be done.
I'm trying to get a users' selected range to display in a cell as stored text.
therefore, If a user selects A1:D7. The text in Cells("G", 10) will be:"A1:D7"
w/o the quotes.
I've attached an example workbook. Here's the formula thus far:
Sub SelectRangeBox() Dim rnBody As Range Dim vaMsg As Variant Do vaMsg = Application.InputBox( _ Prompt:="Please enter the message-text:", _ Title:="Message", _ Type:=2) Loop While vaMsg = ""................................
Actuall maybe my thread should be Titled. user selected cell range displayed in input box save to cell as a text value.
I have a workbook with several sheets. I have written a macro to check if the value in a column is matching with that in another column in another sheet and return the value in a preceding column in the second sheet into a preceeding column in the first sheet. The code looks likes this and seems to be working fine.
Sub Copy_Price_Code() Dim Rw As Long For Rw = 6 To Sheet6.UsedRange.Rows.Count
However, there would be more sheets in the workbook in future and I need to edit the macro in such a way that the user can select the source and destination sheets which I could use in the above macro. I tried to do it as follows but its not working.
Sub Copy_Price_Code() Dim Rw As Long Dim Rw2 As Long Dim Sourcesheet As String Dim Destinationsheet As String Sourcesheet = InputBox(Prompt:="Enter source sheet name. (example: Sheet1).", _
What I need to have happen is that the user decides what duplicate row to delete. The reason that there is a duplicate is that Row 1 has something different from Row 2. In my example above, CU1 is different from CU2. This is what caused this loan number from CR to be duplicated. I need to delete at my discretion one of the 2 rows.
What I would like is to have the user Select Range CR1:CR2 (this is relative in the sheet), run the macro, have it select the 2 row range, compare (relative) B1:B2 are they equal, compare C1:C2, are they equal, etc through the rest of the range. I would like the screen to update and stop with the range highlighted that is and and a MsgBox to click ok to Continue, then continue through the rest of the range. Once it has finished cheking the range, can the user use the mouse to select the range from CR that needs to be deleted, have the appropriate range selected and then the MsgBox Is this the range you want to delete? Y/N........................
I have a protected worksheet with a mixture of locked and unlocked cells, and I'd like to provide an option to allow the user to select a large range of mixed (locked and unlocked) cells and, in the unlocked cells only, pre-populate with a standard formula.
I've got most of it working, but what I need is the specific code that allows the user to specify the range of cells they want the macro to act on.