I have a worksheet named mylist, that I delete, then recreate everytime I run a specific macro. However, I have code in this worksheet that I require, so is there a way for me to insert code to "insert code" on the "re-creation" of the worksheet?
I use excel 2002 but some of my office are on 97, i want to add a small workbook open event code which works for me but debugs for the others?? The code is basically, go to a tab, on that tab and that range sort..
I've developed a little software using Excel Macros & VB. To prevent people from accesing the code I protected the code blocking it from visualization. It seems not enough as an acquaintance of a friend cracked it in 25 minutes. Or so he says. So I'd like to know if there is a better way to protect the font code.
if its possible to insert VB code into an open worksheet using VB code from another workbook.
I have a script which is cycling through workbooks in a folder inserting formulas into cells etc as there are so many. I would also like to add in some VB code to these work books at the same time so as to avoid doing it manually.
i need to insert a raw after a certain code like "TRUE" is the code which is mentioned in column A at different intervals , after that i need a blank raw.
EXAMPLE A B C D E F G H I J K L 1 TRUE 2 3TRUE 4 5 6 7 8 9 TRUE 10
I have a code that needs to be placed on any new worksheets created. All new worksheets are made using VBA code already so they just need to be told to add the code into each new sheet. How do I do this?
I am trying to insert via a command button a new row in 2 different tables but I am finding some difficulties . I have attached an excel sheet as example.
I want to put the vba code into each "ThisWorkbook" in each workbook that is in a folder. I want the code that is placed in each "ThisWorkbook" to run whenever that workbook is opened.
How would I go about doing that? I have this code so far to open the workbooks that are in the folder.
I'm trying to find some simple code that would that would allow me to select a picture from the picture dialog and insert it to active cell at a small size, like 2 1/2 by 2 inches
I have the code below and it runs a report for me but it puts the new tab to the left of my existing tabs. How can I alter the code to put the new tabs on the right?
If Me.cmbCat.ListIndex > -1 Then 'Add a new worksheet Set WSReport = Worksheets.Add(before:=Worksheets(1)) With WSReport 'Check sheetname and keep adding 1 until not found. If SheetExists("Report " & Me.cmbCat) Then Cnt = 1 Do
I am doing up a spreadsheet for work. I have a master sheet which has important 'feeder' info on it. I also have 6 other sheets where the code will reference.
Here is the Data Entry sheet setup.
ColK --> Contains numbers starting in row 2 and ending in row 116 atm, could expand but no further than 500 ColL --> Same as above but with different numbers ColM --> contains formulas which produce the sheet name that the data in ColK and ColL is related to (6 sheets)
----------
I require some code that will look at each row from 2 to 500 in ColM for something other than "out of range" or nothing (the "out of range" or empty ones should be ignored), and for each relevant row it should identify the sheet name in ColM and then identify the cell that is at the cross reference of the 2 numbers from ColK and ColL and then insert a picture at that cell. Each sheet (the 6 of them) has numbers in ColA from A2 and Row1 from B1. The numbers will exact match those from ColK and ColL from the Data Entry Sheet.
Is it possible to use VBA to call an existing Excel function? I want to have code that calls up the "Insert - Object" popup window in the same manner as it would if the user clicked the toolbar.
I need to change the colour of cells depending on contents. The following code works perfectly until I try to insert or delete a row in the worksheet. Then I get Run-time error 13, Type mismatch.
VB: Private Sub Worksheet_Change(ByVal Target As Range) Set I = Intersect(Target, Range("E5:E100")) If Not I Is Nothing Then
I got a code in internet that highlight a cell with equal value after double clicking a cell.
But my problem is I want to clear highlighted cell after clicking another cell (making double clicked cell inactive).
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean) Dim c As Range Dim FirstAddress As String Dim wksh As Worksheet Static ColIdx Cancel = True
I need to use sendkeys to insert code into codepane in VBE.
I use sendkeys "MyFunction()", but the "()" doesn't show up just "MyFunction" I use sendkeys "MyFunction" & chr(40) & chr(41), still only get "MyFunction"
Can VBA code that inserts between written rows a certain number of empty rows (and to be able to specify somewhere in the code the number of rows to be inserted)
I have a requirement where I have to add a row with x columns using vba. this is the code I am using now
k = 17 prodetails = .GetFieldValue("Product Details") sSeats = .GetFieldValue("Seats") If isRecord Then While isRecord Sheets("Products").Rows(k).Insert Shift:=xlDown Sheets("Products").Rows(k + 1).Insert Shift:=xlDown Sheets("Products").Rows(k + 2).Insert Shift:=xlDown ThisWorkbook.Sheets("Products"). Cells(k, Prod6Col) = prodetails ThisWorkbook.Sheets("Products").Cells(k, Unit4Col) = sSeats isRecord = .NextRecord() Wend End If
In this code I have declared Prod6Col and Unit4Col as constants. instead I need to use them as variables like in this modified code. However if i use this code, I get an object definition error.
k = 17 m = 20 (20th column) l = 18 (18th column) prodetails = .GetFieldValue("Product Details") sSeats = .GetFieldValue("Seats") If isRecord Then While isRecord
I am trying to insert 50 tabs (at different points in time during a macro) that each has a state abbreviation. I know how to get the macro to add a tab, but to name it, it wants to select " Sheet 4". The problem with this is, the tab that was created might be sheet 15 or sheet 1, and I need it to be able to name the tab no matter what sheet # it is.
In the sample i have list of codes,also i have picture according this codes: Can i somehow conected pictures and codes? My pictures are in jpg form,can i insert them into cell,where picture should has form as cell has.
When the code from the Data sheet in cell A2 sheet 1,than show the picture conected with this code in Data sheet.
I have data in cells B2:E2 and this can go down 100+ rows.
In column B i have invoice numbers but some cells contain the word "Deposit".
I have sorted this data so that the invoice numbers appear first and then all the Deposits.
I need a code to find the first instance of the word "Deposit" and to insert a row so that all the invoices and Deposits are seperated by a single row.
I have used the following code behind a projects Command button for some time, and works well in Excel 2002/2003. It's used to look for and insert a Picture file, located on the users PC, select cell C2, re-size it to fit inside a bordered cell area and then nudge it over, off the border line.
Sub Load_Image() Dim oPict, PictObj Dim sImgFileFormat As String 'Open file GetPict: oPict = Application.GetOpenFilename("All Pictures (*.tif; *.bmp; *.jpg; *.gif; *.jpeg; *.png; *.cpt; *.tiff),*.tif; *.bmp; *.jpg; *.gif; *.jpeg; *.png; *.cpt; *.tiff") If oPict = False Then End Range("C2").Select Set PictObj = ActiveSheet.Pictures.Insert(oPict) With PictObj .ShapeRange.LockAspectRatio = msoFalse .ShapeRange.Width = 712# .ShapeRange.Height = 510# End With PictObj.Select With PictObj Selection.ShapeRange.IncrementLeft 1# Selection.ShapeRange.IncrementTop 1# End With Range("A1").Select
End Sub
Unfortunately, Excel 2007 doesn't seem to identify the Cell reference "C2". It modifies the Picture size OK but does not position the picture in the correct position. I've tried re-recording it but 2007 misses most of actions.??? Despite my efforts looking on other forums, I don't seem to find a code that works on both version of Excel.
I have written the below code to enter some formulas, validation, and formatting. I keep running into a problem when trying to add the first validation. The debug msg is...
Run-time error '-2147417848 (80010108)': Automation error The Object invoked has disconnected from its clients.
The below code used to work for me perfectly but in the last couple days it's been acting up. The code is supposed to cut out 2 rows from sheet1 and insert it in order of column B in sheet2. Up until a few days ago the code was inserting the 2, cut, rows properly but now it inserts it at the top of the sheet.
I need a macro script that goes to a particular cell in a column based on a criteria (say, locate the first instance where $0.21 appears in col. H), insert a row above it, and fill the row with the text "Note:These are above $0.20"
writing a code where i can copy a worksheet (Sheet1), insert a new worksheet at the END (as the last worksheet), and paste to that new worksheet (which will have a different name each time a new one is added). I am using the code below, but it adds a worksheet after Sheet1 instead of at the end, and it also adds another weird worksheet that says "Dim Worksheet" in one cell, and "Set newsheet = Sheets.Add(After:=Sheets(Worksheets.Count), Count:=1, Type:=xlWorksheet)" in another. This is not in the VBA window, it is just text in a cell in another inserted worksheet. I only want one worksheet added at the end that I can paste too (knowing that the inserted sheets will always have new names).
Code: Sub CreatePercentageSheet() ActiveWorkbook.Sheets("Sheet1").Copy _ After:=ActiveWorkbook.Sheets("Sheet1") ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count) ActiveSheet.Paste End Sub
I have the following code to execute a connection to a DB and return the result of the SQL statement. I have a variable in the statement that I want to be able to change from user input in a single cell. Unfortunately I am unable to get this to work.
This fails and gives me a debug error, however if I declare the condition I want the code executes fine. This would mean having to update the code every time the condition changed or putting the whole query in a cell on the sheet which I do not want to do.