VBA Code To Create A Paste Special Values Keyboard Shortcut
I have written a short VBA code to create a Paste Special values keyboard shortcut.
Is there a way or a place that I can put this code so that every time I open any workbook in Excel, or open Excel itself that this VBA code will be active and I can use the keyboard shortcut?
View Complete Thread with Replies
Sponsored Links:
Related Forum Messages:
Keyboard Shortcut: Copy Formula
Is there someone who know the keybord shortscuts for copy a cell formula, whithout using mouse. Like this: A1: =VLOOKUP(I2;A:A;1;FALSE) Then copy the cell formula to the end of the sheet: A2:=VLOOKUP(I3;A:A;1;FALSE) A3:=VLOOKUP(I4;A:A;1;FALSE) A4: =VLOOKUP(I5;A:A;1;FALSE) With the keybord.
View Replies!
View Related
Paste Can This Be Set To Default To Paste Special Values
Paste can this be set to default to Paste Special Values only ? I have a sheet with a number of lists validated drop down boxes. The sheet is networked and works fine. Problem other users as they are entering information into the required cells they are copying and pasting. Then the inevitable occurs they paste data into the wrong cells the validation from the original cell is pasted as well. Is there a way I can set paste special values only to be the default for the full sheet. Unfortunately we use excel 97 in the office.
View Replies!
View Related
Changing Code From Paste To Paste Special (value)
I've tried to change the line highlighted in red to 'Sheets("Financial Accounts").Pastespecial After:=Sheets("changes")' but the macro crashes. Sub ConsolidatedTotals() Dim BeforeSheetName, NextPageName As String BeforeSheetName = "changes" NextPageName = "Financial Accounts - " & Worksheets("assumptions").Range("c3") Worksheets(ActiveSheet.Name).Select Sheets("Financial Accounts").Copy After:=Sheets("changes") ActiveSheet.Name = NextPageName End Sub
View Replies!
View Related
Editing Code From Paste To Paste Special
I got this code the other day Private Sub CommandButton11_Click() Sheets("Invoice Page").Select Rm = 3 For c = 1 To 5 Rm = Application.WorksheetFunction.Max( Cells(1000, c).End(xlUp).Row, Rm) Next c Range(Cells(3, 1), Cells(Rm, 5)).Select Selection.Copy Sheets(" Records Page").Select c = Cells(3, 256).End(xlToLeft).Column + 2 Cells(3, c).Select ActiveSheet.Paste Application.CutCopyMode = False End Sub And instead of pasting the cells i want it to paste speical so it just pastes values rather than formulas.
View Replies!
View Related
Keyboard Shortcut To Highlight All Cells In A Column From Bottom To Top
What is the best way to highlight all cells in a column from bottom to top? For example, if I'm in column O, row 138, what keyboard shortcut would I need to select ONLY and ALL cells from the row I'm currently on, (in this example, 138) to row 1 and ONLY in that particular column? Keep in mind that the next time I may be starting at row 1,200, it could be different everytime. I tried everything I could think of.. CTRL+A CTRL+SHIFT+A CTRL+HOME CTRL+SHIFT+HOME CTRL+UP ARROW CTRL+SHIFT+UP ARROW CTRL+PAGE UP CTRL+SHIFT+PAGE UP and nothing worked to select everything in that column from the row I'm currently on, to row 1.
View Replies!
View Related
Sort, Copy And Paste Special Code
1. Alphabetize the worksheets that have a red tab color. The number of worksheets with a red tab color will vary from time to time. 2. All worksheets with a red tab color are formatted the same. I would like to copy the same range of cells (AP5:BP9) on all n number of worksheets with a red tab color to a worksheet labeled "Posting". Also, since AP5:BP9 are cells with formulas and formatting, the ranges need to be copied with formats and value and number formats. The first copied range needs to be on line 8 on the Posting worksheet, the second range to start on line 15, etc. 3. Last, but not really last, I would like to start the code with deleting whatever is currently on the Posting worksheet starting at line 8. I have attached a small sample. The sample does not reference the same range as above on the worksheets with a red tab color, nor does it contain the formulas and formatting.
View Replies!
View Related
Force Paste Special Values
I have a workbook where I want to retain FORMATS in all of my cells in all of my sheets, but allow the user to enter data. So I got this code to undo PASTE and instead do a PASTE SPECIAL VALUES: Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) Dim UndoString As String On Error GoTo err_handler UndoString = Application.CommandBars("Standard").Controls("&Undo").List(1) If Left(UndoString, 5) = "Paste" Then 'Only allow Paste Special|Values Application.ScreenUpdating = False Application.Undo Target.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.ScreenUpdating = True End If......................
View Replies!
View Related
Right-Click To Paste Special Values
I have a person who needs to be able to copy and paste values very frequently. She would like me to set up a personal macro on her PC that will allow her to be able to right-click in a cell and have a context item that is paste values so she does not need to go to the paste special dialog continually. E.g: She selects a range from one workbook and copies it, She then selects a cell in a second workbook and pastes the values into the second workbook. She does not mind pasting the formatting, but she does not want to paste the formulas as there are many named ranges in the formulas and if she inadvertently pastes everything, all of a sudden the next time she opens her second workbook there are links to the first. All she wants in the second workbook are the values, not the formulas.
View Replies!
View Related
Paste Special Values In Inputbox
I have a macro that should allow users to change a certain range to values, but I have problems with that last piece. Can anyone tell me what the command is to paste the range as values? Sub Change_Range() Dim UserRange As Range DefaultRange = Selection.Address On Error Goto Canceled Set UserRange = Application.InputBox _ (Prompt:="Change Range to Values:", _ Title:="Range Change", _ Default:=DefaultRange, _ Type:=8) UserRange.Copy UserRange.PasteSpecial Canceled: End Sub
View Replies!
View Related
Paste Special - Values To Delete Formulas.
Sub import() On Error Resume Next Dim wb As Workbook Dim c As Range Dim rngTo As Range For Each c In Range("D1:D10").Cells Set wb = Workbooks.Open(Filename:=c.Value) With Workbooks("DigitalTicketMaster.xls"). Sheets("All") Set rngTo = .Range("A" & .Rows.Count).End(xlUp).Offset(1, 0) End With wb.Sheets("Combined").Range("A2:C100").Copy rngTo wb.Close ............................................. we have a change on our sheet, make it easy for our guys. Column A, is the date. Today 6/29. They enter it once at the top, and it pastes for them automatically (a simple cell = $E$1) But now, when I use the macro, it pastes over the formula that I don't want nor need, and have to call the second macro for. But then everything in that column shoes E1 on my new sheet, which is not the date... and each sheet changes dates, so I can't just have the date all the same. What can I do in my original code to still make it loop, pull all my pages that I tell it to, but paste values only? Would it be possible, in my loop, to highlight my cells, on that sheet... A2:C100, copy them, paste themselves right onto themselves, as values only, then copy over to my new sheet?
View Replies!
View Related
Vba: Doing Paste Special | Add
I am trying to write a VBA code which will add any figure (say X) to the visible cells in the selected range. I am mentioning the visible part becuase my data might be filtered and thus. So far I have been able to figure out the following code(by recording a macro and then going behind the scenses to see the code): Sub Add_X() Selection.SpecialCells(xlCellTypeVisible).Select Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlAdd, SkipBlanks:= _ False, Transpose:=False[/color] End Sub The problem is that how can (if possible) I can pass a parameter to the above code (which will be X; as explained above). There might be many possible solutions??? However one that comes to mind is that when I selected a range of cells and then run my code, a dialog box should pop-up and ask for a # and then then take that # to add it to the visible cells of the selected range.
View Replies!
View Related
Conditional Copy/Paste Special Values Macro
I have 9 worksheets in a book with sheets 1-8 used for data entry, and sheet 9 used for a weekly data upload. Sheets 1-8 are all formatted the same, they just represent different vendors. I need a macro to look through column F (invoice number) on sheets 1-8 and see if the value of each cell already appears in column c on sheet 9. If the value is not found and the row value for column M (sheets 1-8) is >0, I need to copy the data from columns D:K and paste special values into the next blank row on sheet 9. Basically I'm trying to see if I've already paid an invoice, and if not then I need to automatically add the data for payment. I've tried to mess around with a VBA code myself and ended up with a migraine every time. I've also tried to use the advanced filter, but the cell values I need to copy over contain formulas and conditional formatting...not to mention I can't delete the data on sheet 9 that has already been added.
View Replies!
View Related
Paste Special As Values Macro Only Works Intermittently
I often need to use Paste Special... Values, using Excel 2003. So I recorded a Macro into "Personal.xls" and assigned a shortcut key combination "CTRL-Shift-V" so that it would always be available. I first select one or more cells and hit CTRL-C to copy to clipboard, click on another cell, then hit CTRL-Shift-V to run the following macro: Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False It often works . . . and it often fails. When it is working it seems to keep working over and over. When it is failing it keeps failing. So it is almost as if there are two "modes" of operation, which for lack of terms, for this post I will coin the terms "fail mode" and "fixed mode". Once I am in one of the two modes, it stays there for a while. When it is in the "fail mode", I always get the dreaded: Run-time error 1004: "Pastespecial method of Range class failed". Since this problem is very intermittent, I believe this is why there are so many posts in the Internet about this, and so many people are replying back "it works fine for me". I have seen many solutions offered but none work so far for just a simple shortcut key to do a PasteSpecial :Values. Some solutions "work" . . . such as adding the PasteSpecial button to the Toolbar, or pressing ALT-E-S-V <Enter> - but both of these bring up the Paste Special dialog box which I want to avoid. I spent days trying the many solutions offered but so far all I have found is a trick to convert Excel from "fail mode" to "fixed mode". The trick is to add a line to the macro to first do a "Paste Special: Format: Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False ...................................
View Replies!
View Related
Copy And Paste Special Values Issue/question
In the code below, I am copying information from a master sheet to various sub-sheets, but I cant figure out how, based on the way I have written my code, to copy and paste special values. I commented out the line that I need pasted special values. Dim intData As Integer Set wsData = Worksheets("Data") LastRow = wsData. Range("A" & Rows.Count).End(xlUp).Row Set wsCrit = Worksheets.Add wsData.Range("E3:E" & LastRow). AdvancedFilter Action:=xlFilterCopy, CopyToRange:=wsCrit.Range("E3"), Unique:=True LastRowCrit = wsCrit.Range("E" & Rows.Count).End(xlUp).Row For I = 4 To LastRowCrit Set wsNew = Worksheets.Add wsNew.Name = wsCrit.Range("E" & I).Value wsNew.Range("a3").Value = "Estimator" wsNew.Range("a5").Value = "IP Number" wsNew.Range("b5").Value = "Project Name" ......................
View Replies!
View Related
Copy To Another Sheet, Rename And Paste Special Values
i would like to copy a sheet to another sheet, rename, copy and paste special values. but after the sheet is copied to another, the macro stops working...? Sheets("Proposal").Copy After:=Sheets("Proposal") 'rename... ActiveSheet. Name = "ProposalEmail" ActiveSheet.Copy ActiveSheet.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks _ :=False, Transpose:=False
View Replies!
View Related
Copy Multiple Worksheets With Paste Special (values)
I am trying to create a macro to copy multiple sheets to a single named worksheet, all within the same workbook. The code below works, except I want to copy only the data (no formulas). Can I add code to paste values, or do I need to start over? Public Sub CopyandPaste() Dim ws As Worksheet Worksheets("Summary").UsedRange.Delete For Each ws In Worksheets If ws.Name <> "Summary" Then ws.Range("a2"). CurrentRegion.Copy _ Destination:=Worksheets("Summary").Range("A65536").End(xlUp) End If Next ws End Sub
View Replies!
View Related
Copy Paste Special Values Of Named Ranges
Been playing with this for some time and can't quite figure it out. I'm trying to copy a named range and paste special value to another named range of the same size. I recorded a Macro that does what I need, and I'll use if necessary, but thought I'd try to consolidate the code a bit and can't get it to work. The recorded macro is as follows: Sub PasteRanges() Application.Goto Reference:="DataCopy30Yr" Selection.Copy Application.Goto Reference:="DataPaste30Yr" ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False, _ IconFileName:=False End Sub My attempt to consolidate was this: Sub PasteRanges() Range("DataCopy30Yr").Copy Destination: Range("DataPaste30Yr").PasteSpecial (xlPasteValues) End Sub I get the Run-time error 1004 Copy method of Range class failed when I try to run this. Again, I can use the longer version with no problem, but in the interest of learning and since I have spent some time not being able to come up with the solution, I thought I'd ask the experts opinions before I gave up on it.
View Replies!
View Related
VBA - Find Copy Then Paste Special
Im trying to get some VBA to search in my worksheet to find a match to the value of cell B5 (the value of B5 changes depending on user choice), then once a match is found I want to highlight from the matched cell to the right 5 columns and down to row 193 (so in total 6 columns would be highlighted down to row 193), then copy and paste special values over those cells.
View Replies!
View Related
Copy Paste Special As Values Based On Validation Cell Contents
Need VBA macro that will copy & paste (Special > AS VALUES) from one of two (Data A & B) sheets based on the contents of a validation cell ($D$4) in a third (Report) sheet? The destination starting cell would be $F$11. ALSO - I'd like to have the Named Ranges "DataAExtract" & "DataBExtract" used in the code (for the COPY region) so I can see an example of how to reflect my actual named ranges in my working file. The reason for doing this is that the "c.Characters...." lines in my conditional formatting macros (attached) are not working on cells containing formula output (in my working file the Report page is all populated by VLOOKUP results), but the macros run fine on hard-coded values. In my attached workbook, I'd like to have the "NEW" macro for the copy & paste step fire first in the sequence of macros running after the FORM button-click (control located in cell $D$5 of the Report sheet), whether that's by writing a new macro and calling mine before the new one ends, OR by consolidating all of my macros plus the new one into one smooth progression. With this low-tech approach I can get updated VALUES into the report area once the user selects a data source and a customer on the report sheet. The COPY ranges in my working spreadsheet will update based on the selections made in the report page. I tried recording a macro and then modifying the recorded code to add the "If > Then" functionality I'm looking for, but I'm pretty green when it comes to VBA code and syntax.
View Replies!
View Related
Paste Special Values Of A Formula To A Cell But NOT From A Defined Source Cell
my destination cells will have formulas like: ='E:My WorkTestData[CCC.xlsx]Input'!$S$31 Everything works fine. But I don't want the destination cells to display the full formula, but the actual Value only I thought of a way to build a script that first builds the formula to one cell then Copy Paste Special value of that Cell to my desired Cell. But when the code runs The cursor moves back and forth all the time...
View Replies!
View Related
Create Macro Code With VBA Code
I'm trying to add buttons to an excel spreadsheet at runtime. Each row in the spreadsheet should have its own buttons. I was able to create and edit them with the ActiveSheet. OLEObjects.Add() function, but after that, when i was trying to create code dynamically to react on the buttons' click events excel crashes (actually it works for one button, but not if my routine for adding a new button and event code is called more than once in a row!) The code below works if the AddCmdbuttonWithCode() is called once, but crashes if it is called two or more times. Excel tries to restore the document after the crash and the first button and its corresponding click event code is visible and works... but NOT the second button and its event code... The only way I can create multiple buttons right now is by calling my method once per click, opening the vba editor, changing the parameters for my AddCmdbuttonWithCode() routine and execute it again. After that I have mutliple buttons in different lines which all work fine (so the concept seems to work). The problem seems to be the insertLine method, since everything seems to work if i leave it out (except for the code generation of course, since this is done by this part of the code :-) ). Is it possible that calling the insertLine Method can't be called multiple times? I don't know... any ideas? Feel free to test my code - it's small, easy to understand and has comments. 'this code calls the method which creates the buttons in specific cells with specific names Private Sub CommandButton3_Click() 'the first call always works! AddCmdbuttonWithCode "Edit_111_111_114", 23 'the second one crashes excel AddCmdbuttonWithCode "Edit_111_111_115", 27 End Sub
View Replies!
View Related
Using VBA To Create VBA Code On The Fly
I have a vba module that reads a value from a txt file and saves that value in a variable called "iniInfo". I want to permanently assign that value programatically by using VBA code to create a Public variable e.g. "PUBLIC CONST conFIg = iniInfo" in my modGlobalVar Module. (Of course, this would only create the code if the "conFig" variable doesn't already exist.)
View Replies!
View Related
Create A Shortcut To A File, Not Hyperlink
How can I change the text color within a cell when I am using a concatenation formula? I have the following formula; =" Total Bonus Earned ("&TEXT(A2/VLOOKUP($A$1,PR_DB,2,False),"#0.0%")&" of 2006 Earnings):" In the text function portion I would like to format the result in red. An example of the result of my formula I am seeking is as follows; Total Bonus Earned (10% of 2006 Earnings): Do I need to create a custom format and if so how do I call it up within the text function?
View Replies!
View Related
Code To Create Directories From Cell Values
I have a CSV file and would like to create directories on my hard drive and the names of those directories will need to be pulled out from this csv file: [B1:B86]. For example I have the following data in my csv file: B1: folder1 B2: folder2 . . . And would like to create folders on my hard drive so that folder names will be: folder1, folder2, ...
View Replies!
View Related
Create Comparison Code In VBA
I have to do monthly comparisons of two excel worksheets, one being a vessel timesheet and the other being an excel download from manpower software that we use. The comparison that is being made are days of the month, whilst the unique identifier between the two sheets (To make it easier to understand I will call them sheet1 and sheet2) is an employee ID. Both sheets, alongside the name and employee ID, list all the days of the month that employees have worked. If they have worked, there is a "1" under that day, if they have not the cell is blank. What I currently do manually is: 1: Search for the employee ID (and/or name) in sheet1 and compare the days with the employee ID in sheet2. 2: Highlight the differences 3: Move onto the next employee ID All differences are highlighted in sheet2. Differences highlighted are in the days only, where if any days are missing/extra in either sheet, then the particular cell(s) are highlighted in yellow. If an employee is missing from sheet1 but is in sheet2, then all the days are highlighted (in sheet2). If an employee is missing from sheet2 but is in sheet1, then that particular employee is copied to the bottom of sheet2 (after last row). As this is horribly complicated to explain, I can attach an example if this is sounding rather inexplicable? Is it possible to attach a xls to a thread?
View Replies!
View Related
Anyway To Create Shortcut Icon To Open A Specific Worksheet?
Is there anyway to create a shortcut icon that I can place on my windows Desktop - That when launched will open a workbook to a specific worksheet/tab. Has to be a windows shortcut as the workbook is auto generated eachday and sent to me, so if I add vb code it will not matter as I will get a new workbook the next day thus wiping out the vb code. The person who compiles it leaves it on a certain tab that I dont need, but is commonly used by other people - so I would like a shortcut to skip that worksheet and take me to the worksheet that I need to use.
View Replies!
View Related
Paste Values Code Returns 0;
I have a simple code that opens 2 workbooks and then copies and pastes a cell from one to the other. The cell that's being copied is a formula by the way. My problem is that the copy and paste keeps returning a "0" value, instead of the correct number. I am thinking it's probably because the file from which it is copied is very large and because the operation barely takes a second, it doesn't allow it enough time for the formula int he cell that is being copied to calculate the value.
View Replies!
View Related
VBA (Keyboard Strokes)
I've programmed in many different forms of BASIC in my days, but I'm having too much trouble with VBA, and can't figure out if it's me or if it's the version of Excel I'm using (2002). I wrote a program in Excel, where if certain cells contain values other cell's calculations will become active. I want to click on a button that I created on the spreadsheet, then be able to select different keyboard strokes to activate these cells. I understand that there are 3 event codes that circle around this concept and that is KeyDown, KeyUp and KeyPress. Whenever I type in what MS Help told me to type in for these events, it always returns a runtime error.
View Replies!
View Related
VBA Macro Code To Create Multiple Charts
I need to create 63 charts from data which I have in two columns. I want to create multiple charts using one macro. For the first chart I want it to use cells K2:K80 as the x values, and M2:M80 as the y values. For the next chart I want it to use cells K81:K159 as the x values and M81:159 as the y values. For the next chart I want it to use cells K160:K238 as the x values and M160:M238 as the y values. I want to continue this, creating a chart for every 78 cells of data, all the way until the 63rd chart which uses K4900:K4978 as the x values and M4900:M4978 as the y values. I have created the following macro by " recording." This macro generates the first chart that I want: Sub Macro5() ActiveSheet.Shapes.AddChart.Select ActiveChart.ChartType = xlXYScatterSmoothNoMarkers ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection(1).XValues = "=Sheet1!$K$2:$K$80" ActiveChart.SeriesCollection(1).Values = "=Sheet1!$M$2:$M$80" ActiveChart.ChartType = xlXYScatterSmoothNoMarkers ActiveWindow.SmallScroll Down:=-3 End Sub How can I alter this macro to create all 63 charts?. It seems like there is an easy way to do this, but I don't use macros very much (at all).
View Replies!
View Related
VBA Code For Copy & Paste
I created this spreadsheet a few montsh ago to help with forecasting for my companies products. The tabs of interest are the HIST vs FORECAST, FORECAST TOOLKIT, and the FORECAST TABLE tab – now the FORECAST TABLE tab is always hidden and if you unhide it then it will rehide itself once one of the macro’s is run. I set it that way to prevent people accidently making adjustments to the forecast data. The way the sheet is supposed to run is that when you are on the hist vs forecast page then you can click one of the grey buttons on the right which will then graph the numbers for the relevant product on the toolkit page – so far so good, this bit all works fine, there are separate macro’s for this each named after the product they control. Then once you are on the toolkit you can play about with the numbers until you come up with a 6 month forecast you are happy with which will be on the 6 cell line in the bottom right were it says “ IMPORT”. You can then click on the “IMPORT” button which will then copy and paste it back into the forecast table under the relevant setting – the macro for this is called IMPORT2 and it works off a “product” range and a “ date” range – again this pretty much works as intended. Sub IMPORT2() Dim nDate, nProd With Sheets("Forecast Toolkit") nDate = Application.Match(.Range("O31"), Range("Dates")) + Range("Dates")(1).Row - 1 nProd = Application.Match(.Range("I3"), Range("Products")) + Range("Dates")(1).Column...........................
View Replies!
View Related
Limit Scroll Area - Code Activates Only On Mouse Or Keyboard Input
I have a worksheet that serves as a navigation page for the workbook and use the following code to restrict from scrolling off the viewable content. The problem is that the code doesn't kick in until either a click if the mouse or keyboard input. This initially leaves the worksheet open for scrolling until input is received. How do I make this code activate when the wb is loaded? Code in the Thisworkbook module already makes the menu the visible sheet, and code limiting the scroll area is in the sheet module. Private Sub Worksheet_SelectionChange(ByVal Target As Range) With ActiveSheet .ScrollArea = "A1:L11" End With Range("A1").Activate End Sub I've also tried using "Range("A1").Select", but it doesn't work either. How can I get this to work correctly?
View Replies!
View Related
Paste Special Value
How would the code be changed below to be Paste Special Value? The numbers copied are changing every few seconds and I want a snapshot of it. im TheRow As Integer Sheets("Loader").Range("C5:AC5").Copy TheRow = Sheet2.Range("A100").End(xlUp).Offset(1).Row If TheRow < 6 Then TheRow = 6 Sheet2.Cells(TheRow, 3).PasteSpecial If TheRow = 6 Then Range("B6").Value = 0 Else Cells(TheRow, 2) = Cells(TheRow - 1, 2) + 1 / 24 Cells(TheRow, 1).Value = Date ActiveWorkbook.Save LastSoon = Now + 1 / 24 '1 hr from last time Application.OnTime LastSoon, "Capture" 'set up for next hour
View Replies!
View Related
|