I have finaly completed my project to include all the bells and whistle needed to make an ok task a bit more exciting. However, i am having a problem when the code is executing. It seems to "break" at random points in the process. I am not able to duplicate this error at my home (nor do i want to) and I can not quite figure out what is causing this as it only happens at my work computer. I have tried my coworkers computer and the code executes flawlessly like at my home.
Strangely enough, when the code breaks I am able to hit 'continue' and it continues on its way until the next hiccup. Please assist as this fluke is causing my brain to spiral.
I have a worksheet where the print area is 16 columns and ~90 rows. have it set to print on one page in page set-up, which generally scales to about 80%, and this has worked fine for years. A couple of months ago I was traveling for work, but got a call that the worksheet was printing each cell as a separate page. My co-worker messed around with it and it seemed to fix when she cleared and reset the print area, and has been working fine ever since.
Today it popped up again. It is setting automatic page breaks every few cells so page 1 is A1:A7, page 2 is A8:A11, etc...Both Print Preview and actually printing a page show me my few cells in the lower right hand corner of the page. Viewing the page break preview shows that they are all automatic page breaks, and if I try to move them I get the error that Microsoft Office Excel cannot move the page break because doing so would reduce the scale below the minimum 10%.
As I mentioned I have it set to "fit to" 1 page high and 1 page wide, which it right now is saying sets the scale to 10%. If I instead choose the scaling to be "adjust to" and set to 100% it only wants to take up 4 pages, but if I try to manually drag the break over afew columns it reverts back to wanting to print every few cells.
I want to create an automatic page break at each value change in Column A, and also a page footer that "restarts" at each change in the same column. For example, I would like a "Page x of y" footer, but I don't want "Page 1 of 3,500", I want "Page 1 of 3", etc...every time that Column A value changes.
I would like a solution for the automatic calculation of the end date and end time for project tasks. I have already spent hours on the issue, thanks for any help on this.
The parameters are: A1 = Start time 08:00 B1 = End Time 17:00 A2 = break lunch 12:00 B2 = back from lunch 13:00
Task parameters
A5 = start date 01/03/10 (entered manually) B5 = start time 10:00 (entered manually) C5 = duration 02:00 (hrs entered manually) D5 = "end date" >>> (to be calculated exluding breaks and holidays) E5 = "end time" >>> (to be calculated exluding breaks and holidays)
the next line should be filled in automaitically according to the hours needed and the previous end date & time
A6 = "start date" >>> (after line 5: to be calculated exluding breaks and holidays) B6 = "start time" (after line 5: to be calculated exluding breaks and holidays) C6 = duration 14:00 (entered manually) D6 = "end date" >>> (to be calculated exluding breaks and holidays) E6 = "end time" >>> (to be calculated exluding breaks and holidays)
I have a workbook with several worksheets. The numbers entered by the user in the cells C7:C9 of sheet "A" will be used to calculate some values in sheet "A" as well as in sheet "B".
Calculations on both sheets involve macros: macro "scale" on sheet "A" and macro "sort" on sheet "B".
I used this code to execute macro "scale" on sheet "A" triggered by the Worksheet_Change function:
Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("C7:C9")) Is Nothing Then Exit Sub Else scale End If End Sub
now, I want to execute macro "sort" on sheet "B" practically at the same time (with the same worksheet_change condition for sheet "A")
All off my attempts resulted in running "sort" in sheet "A" which is not what I want. I couldn't get it to execute the macro in the other worksheet. Already tried "With Worksheet("B") and "Dim ws As Worksheet, Set ws = Worksheets("B") - no luck...
I have a workbook which autosaves and closes if no data is input for 10 minutes. It resides on a drive accessable by all our team and is set so that only one person can have read/ wrote access at a time. It tests for read only, shuts down if it is and saves and shuts down if not.
I have noticed that it doesn't work if the workbook is waiting for input.
I.e. someone starts to enter text, or something, in a cell, then goes off to make a coffee or whatever leaving the entry cursor sitting there blinking. It will not shut down after the ten minutes with no input.
if I can send text to a macro and have VBA treat the text as a line of code?
Suppose in a worksheet in cell A1 there is the following "text" msgbox "hi there"
can you get vba to do the following:
Sub runtext() Mytext = sheets(1).range("a1").text XXXXXX Mytext End Sub
where "XXXXXX" is a method or command that will cuase vba to evaluate the text string and run it as a line of code (returning a message box saying "hi there")
I don't want to send variables/objects to an existing method in VBA - I want to send the method to VBA....
I am trying to find an item within an array and then VBA could execute code.
Here is an example:
[Code]....
LookupItems =("text", "value", "book") or should I acutally be using Split("text,value,book",",")
For Each sht in ThisWorkbook If sht.name = array(LookupItems) Then.....execute code
[Code] ....
So basically in this example I want to loop through all the sheet names in the workbook and if any of the names in the arrary are found it will execute the code for those particular sheet names.
I know alternatives are the select case or write an if statement for each value I am looking up or even use an OR for each value to lookup; but I just wanted to see if this method was even possible as it would be less coding.
I have a file I created which works fine for me, on my machine at least but there are two issues I'm trying to sort out.
The first issue is I need to share the file with others who may not have the same access rights. I have something loading in the Workbook_Open event which I want to bypass for users who do not have access to a specific folder. So I was trying to check their access using Dir(path) = "" at the top level folder to see if any files are present (which there are). My assumption was that if it finds files it's safe to assume they have permission and it's ok to continue, otherwise they don't in which case I want abort the rest of the code. This seems to work fine for me but I tried testing with someone I know does not have access and it gave her a compile error.
Part of the code in macro utilizes FileSystemObject which seems to be the line where the code bombs on my coworkers machine. The FSO seems related to appears related to the Microsoft Scripting Runtime reference, but it's not enabled on my machine or any of the others. I vaguely remember having to do something on my machine awhile back for the life of me don't remember what it was.
The second issue is an MS Forms error: "Could not load some objects because they are not available on this machine." appears when opening the file on three of the machines I tested but it does not appear on my machine. I've tried looking at the references and could not find any differences between the machines. I pored through various postings online and it appears it might be worth re-registering the DLL/OCX files but we need admin rights to do that so I will need to open a request with our support team.
I have written a vba code which does some calculation on the data on sheet 1 and then puts this data on sheet3 and after the calculation is done it puts the result on a few comboboxes on sheet2. Now the issue is while this whole calculation is performed by excel, I can see the movement in between the sheets. I want to avoid seeing this movement ?
Is it because of multiple Sheet.Select statements inside the vba code ?
i need code that can look at cell d23 and take that number( say it is 13) and break it down into groups. that have 3, 4 or 5 per group. in this example 13 can be broken down into
Is there any way, in which i can make my code dynamic?? For example, in a code written in VBA, there is a reference to particular sheet, say "ABC". If i change the name from "ABC" to "ABCD" from excel, the underlying code should change automatically from "ABC" to "ABCD".
I have a macro that gets activated as soon as i select the sheet which the macro is situated in. This is not so great because if i am bringing something from the clipboard the automatic macro erases what i have copied and therefore i cannot paste anything. I can make the automatic macro run from a different sheet. Here's how:
i have one excel sheet (refer attach) i give some example 7 to 8 customers, but in sheet nos. Of customer name a to z suppose to 3000 customer list. Now i want to create automatic customer alfa- numaric code.
I have already got an anwer for this long back from this site. The code was writted by Mr. Krishnakumar the thread is here :[url]
i need some changes to be made in this code. The existing code creates and updates the details in the sheets automatically from the master data. I just need the sum of Column I in all the sheets after the last row of Column I.
selecting all the sheets and typing the formula in I column is not possible because, the last row in Column I is different in all the sheets. In sheet 1, the last row of Column I is Row 15, in sheet 2 Row150 is the last row. I guess something could be done in macros.
follwing is the existing Sub TestIt() Dim sWS As Worksheet Dim Sellers As Range, Seller As Range Dim lRow As Long, fRow As Integer Dim CopyRng As Range, ws As Worksheet
I have a combobox which is used to select data (stock symbol) from a list. Following selection of the stock symbol, a VBA routine is invoked from a radio button which accesses the internet to get data for the selected stock. Currently, this is a two step operation. I tried to cut out the need to click on the download button by calling the GetData sub inside the combobox sub as shown in the code below.
Application.ScreenUpdating = False Dim s As Variant Dim resp As Long resp = MsgBox(prompt:="You are about to clear ALL current year payroll information. Are you sure you want to continue?", Buttons:=vbYesNo) If resp = vbNo Then
The code which you provided works fine no problem for a page break. I need to run the macro for the page break by asking the input file for page break to be done.
For Example, If excel filename "A" contain the code which you have given need to ask to input the filename "B" and process need to be done in file "B".
I have added some code to your code which you provided but it gives error message "1004" "Method 'Range' of object '_Application' failed" at following line :
Set rng = oExcel.Range(Cells(2, 2), Cells(Rows.Count, 2).End(xlUp))
I just want to have a column sorted by Z-A order and then A-Z by the same button, I recorded 2 macros on 2 buttons and tried to join codes with "if, elseif".
I wanted to know If there a way to hide the process of executing macrob (vba)? I have a long macro that runs on a file and I want to hide the process. I know there is an option to it, I just don't know it.
The error trap does work when there is an error, but it also runs at the end of the code when there isn't an error... I'm not sure what I've done wrong. When I test with data that is correct, it still runs through the code when it gets to the bottom. Have I put the error trap in the wrong place?
I have put in bold the section of the code with the error trap.
Option Explicit
Const TargetDB = "Group Life Pricing Tables v0.1.accdb"
Sub HMUK_Val() Application.ScreenUpdating = False
'define variables to be used in the process Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Dim fld As ADODB.Field Dim sSQL As String Dim SchemeInfo As Integer Dim CurrentAge As Integer Dim CurrentRow As Integer Dim CurrentSex As String Dim Message 'check that Scheme data has already been entered For SchemeInfo = 1 To 13 If Sheets("Working Info").Cells(SchemeInfo, 2).Value = "" Then Message = MsgBox("Please ensure all Scheme information has been entered before processing member info", vbOKOnly, "Warning") Exit Sub End If Next SchemeInfo
I've a macro (I recorded) that executes a query (Oracle) and returns rows that exceeds the max (65539). How do I go about adding another sheet therefore allowing the query to continue?
I know how to do it via opening a text file and importing, but do not know how to do it with the use of a query.
I have a Worksheet_Change method in my sheet module which has suddenly begun working selectively. I have several target ranges in my worksheet that I need to watch for changes. One range of cells is all pull-down menus (a list of electrical loads through excel's validation), another two cells are looking at the name and location of an electrical panel.
When the user selects an electrical load, the worksheet_change method updates a legend of definitions. When the user enters a new name or location, the method updates similar fields elsewhere on the same sheet.
The problem is, excel has stopped executing worksheet_change when a load is chosen or location entered. It only executes when the aforementioned load and location are deleted. However, the name field triggers worksheet_change just fine!
I have attempted to put breakpoints on the worksheet_change method; Excel does not even execute the method as described above. I've tried breaking on the toggling of Application.EnableEvents (which occurs early on in the execution of worksheet_change). I currently have a global watch on Application.EnableEvents and I'm quite sure it's TRUE before I attempt to trigger a worksheet_change event.
My next step is to create a brand new workbook and copy my spreadsheet and code into it. I'll post the results of that experiment.