VBA Code - Copy / Paste And Then Format Range

Apr 13, 2012

I have this code that copy/pastes a range from another sheet for every nth row. In the code I have pasted cells I need to merge the cell with the cell to the right and format it. I thought I was doing ok but the code keeps returning an error (run-time 1004) and I don't know the solution, it is beyond my level of VBA.

Sub test()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim lngRowCounter As Long
Dim newRowCounter As Long

[Code] ...

The code in red is the problem and I have commented it out so it can run, but I need it to merge and format. I don't know how to address range/cells in column B and C together (they are the two cells I wish to merge and format).

View 2 Replies


Application.inputbox: Range To Copy And Paste The Range's Link And Format To A Different Sheet

Oct 7, 2009

Need a code using application.inputbox to get a range, then use that range to copy and paste the range's link and format to a different sheet? The specifics don't matter, I just can't figure out the syntax. Here is what I have currently:

View 2 Replies View Related

Copy Range X Times & Paste & Format

Oct 9, 2007

I have a range of cells that is 10 rows high. I want to copy and paste this range 11 times while identifying each of the 11 copies of the range, such as; 02,03,04...12.

Please see attachment for an example of what I am trying to do.

Does anyone have an idea of how this might be done in VB?

View 3 Replies View Related

Copy And Paste Actual Format From Conditional Format?

Apr 12, 2012

I have a range which has conditional formats based on other cells. I want to copy this range into another sheet and retain the current formats as fixed formats without copying the conditional formulae. ideally in VBA.

View 5 Replies View Related

VBA Copy, Paste Rows And Format

Apr 19, 2006

I have been trying to set up this macro to copy and paste rows where a tick box is checked. The macro needs to transfer the row A:H over to sheet 2 then insent the data acording to property title either A, B, C etc. into formated tables which then feed into a bar and pie chart. I have tried posting this question up in sections hoping that i could get the bits of code i need and then work out how to do the macro but I have had no luck since my VBA skills are poor. I have attached the file

Private Sub CommandButton1_Click()
Dim lRow As Long, lRow1 As Long, lRow2 As Long
Dim Target As Range
Dim vTemp As Variant
Dim WS2 As Worksheet
Set WS2 = Sheets("Sheet2")
lRow = WS2.UsedRange.Row + WS2.UsedRange.Rows.Count
For Each Target In Range("I1", Cells(Rows.Count, "I").End(xlUp).Address).SpecialCells(xlCellTypeConstants)
vTemp = Target.Value
If VarType(vTemp) = vbBoolean Then
If vTemp = True Then
vTemp = "*"
On Error Resume Next
vTemp = WorksheetFunction.Match(" Total*", Range("A" & Target.Row, "A" & Rows.Count), 0).....................

View 2 Replies View Related

VBA - How To Copy Paste Date In Dd/mm/yyyy Format

Aug 27, 2012

the date I want to copy paste is in [dd/mm/yyyy] format in a single cell.

I want to isolate the [dd], [mm] and [yyyy] and write them down in 3 different cells. How can I do this?

View 3 Replies View Related

Copy Paste Date Value & Format To Next Empty Row

Jan 23, 2008

Is it possible to have a macro copy a range of cells (A1:K1) and place it in the next empty row? My first row has formulas in it to grab information from a separate sheet within the same workbook with special formatting so I can import it to another program. What I want to be able to do is take that first row, use my macro button to copy and paste (only text, not the formulas) the information into row 2, then when the information changes in row 1 with new information (from the other sheet) it will copy and paste the new information into row 3 and so on.

View 6 Replies View Related

Copy And Paste Table Into String In HTML Format

Dec 22, 2008

I want the same affect as copy a table and pasting into the email. So i guess i need to copy a range and save as html in a string. It seems like it would be simple since its just copy and paste into the email, but i've been unable to find anyting on it.

View 3 Replies View Related

Copy-paste From Csv To Xls Macro > Wrong Date Format

Apr 27, 2009

I'm exporting a csv file from a membership database with the attendance of members. With a macro i open the file and copy the contend to excel. With the macro the column for the date has *randomly* wrong formats. Example the date in column B:

Aasia Tallah19-03-2009 19:33
Aasia Tallah17/03/09 7:49 pm
Aasia Tallah15/03/09 7:53 pm
Aasia Tallah14/03/09 6:34 pm
Aasia Tallah03-12-2009 20:05
Aasia Tallah03-11-2009 19:56
Aasia Tallah03-10-2009 19:54

I try to change the format of the column, but that does not work. Rows 2,3 and 4 seem to be text but they are not. If i access the edit bar for example the 17th of march and store without changing anything, it changes to the format of the first row. That is how i want it. If i copy the column by hand, every thing is fine.

All of the following i tryed:
- format date column of the csv before copying... failed
- copy special with only pasting values... failed
- preformat the column i paste the date to... failed
- delete the sheet i paste to and create a new one... failed
- copy the macro to a new workbook... failed

View 2 Replies View Related

Copy/paste Code ....

Nov 1, 2009

I have two files and need to copy the information from columns B,C,F,H rows 5 true 29, and past it in the other file in Columns B,D,G,J; rows 3 true 35.

The code that I have works fine, but have one problem - it past the info in the rows starting from 37 instead from row 3. Here is where I need your help. The code is triggered when the condition Arr ( arrived) is chosen in the column AH ( file Delivery Status) and then the specific warehouse is chosen in the column AI. To make it easy I have left only one warehouse as a choice.

Attached you can find sample files ( I have delete the info from the heading cells as it was in another lenguage)

View 14 Replies View Related

Copy Paste Code

Nov 9, 2009

I need a little look on a Copy Paste Code, as bellow:

View 3 Replies View Related

VBA Code For Copy & Paste

Dec 4, 2009

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.

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 5 Replies View Related

Copy/Paste Code Problem

May 12, 2008

I'm using code that SHG provided for me here; http://www.excelforum.com/excel-programming/630464-sheet-macro-for-preventing-paste-not-working.html

It worked great in the first workbook I set up but I just set up a new workbook and it's not doing the same thing. For example, it allows me to copy items from column A which have 1 type of validation (restriction on text) to another column which has a formula validation.

It still won't allow me to paste from outside a validated range to inside but I need to prevent people from screwing up the validation between columns.

View 13 Replies View Related

VBA Code - Copy Particular Cell And Paste As Value

Mar 8, 2013

I have the following bit of VBA code which copies a particular cell and pastes it in the next available cell in column "AD", but I need to paste it as a value. How do I incorporate this into the code?

Sub copypaste()
Worksheets("USD IR Swap 10 Yr").Range("L5").Copy _
Destination:=Worksheets("USD IR Swap 10 Yr").Cells(Worksheets("USD IR Swap 10 Yr")
.Rows.Count, "AD").End(xlUp).Offset(1, 0)
End Sub

View 5 Replies View Related

VBA Code To Copy And Paste In Different Worksheet

Mar 14, 2013

I am looking for VBA code that will select a data validation cell, copy the selection, and paste the value of that cell in a different worksheet.

The data validation list is in cell L47. The user will select a date from cell D31, type a description of activities in the adjacent column and then select initials from the aforementioned validation list in cell L47. I need the code to fit into a button I created so that when they click it to approve the activity, the code will copy the value of the initials and paste it into column AB in a separate worksheet. Column AB runs parallel to column A, which contains all of the dates located on Sheet1 in cell D31. I think I might need some sort of loop to run this so that it pastes initials on the correct date.

View 3 Replies View Related

VBA Code To Copy And Paste A Shape

Apr 14, 2013

I have a shape called "Company Logo". Code to copy the shape from sheet 1 and paste to sheet 2?

(I tried macro record but had trouble when I pasted it into another macro).

View 4 Replies View Related

Copy Paste Between Sheets In Code

Sep 18, 2007

I want to automate the transferring of specific pieces of data from one spreadsheet into another spreadsheet. There are many project spreadsheets that all feed into a resource plan spreadsheet showing every employee, what projects each of them are on, and how many hours they are spending on each project for the quarter.

Now what I would like to do is to automate this process of feeding the data from the many project spreadsheets into the resource plan spreadsheet. With transferring the specific data from the one to the other. Basically I need it so that excel looks at the project spreadsheet copies the name of the employee and the hours they have worked each week for the quarter and paste It into the big resource plan. What I am finding tricky is knowing how to make it automatically paste into the right area as in copy an employee and paste the details in the same employees cells in the other spreadsheet.

View 2 Replies View Related

Sheet1 Row Range Copy To Sheet2 Firs Blank Row In Same Range Paste As Text?

Mar 16, 2013

Trying to assign code to comm. button on User form to copy lets say:

(sheet1, rangeB2:B21) to (sheet2, first blank row rangeB2:B21) and paste it as text value one more question: what to be aware in case of sheets format (merged cells, hidden rows...)

View 4 Replies View Related

VBA Code To Unhide A Row When A New Entry Is Copy And Paste

Apr 26, 2014

I have 4-5 worksheets (sheet1,sheet2,etc) on a workbook. All of the rows except for the ones that are filled in are currently HIDDEN.

I have one worksheet called "Add record" which has a VBA code that adds a record to any of these sheets.

When it does this I want it to recognise when pasting the new record into any fo the sheets.. IF the row is hidden, the sheet needs to reveal that row.

I'm desperate trying to get this to work!!

Here is the code I have so far! This is a command button macro used in the "Add Record Sheet" I have FOUR different versions of this code. Each one adds the data to a specific sheet.

[Code] .....

View 1 Replies View Related

Copy/Paste Code Running Very Slow

Apr 4, 2009

The code opens a varying workbook with the same format as the source workbook and copies specific columns into the source workbook.

It is currently taking about 20seconds to run.

The worksheets are protected and have merged cells hence the call TestMe line.

View 13 Replies View Related

Code: Copy And Paste Based On Condition

Jan 25, 2010

I would like a code which looks on the worksheet “Racks” and if Column A is "Y" then copy the entire row and paste it on the to sheet “Summary Racks”. I would need it to then find the next instance and then continue to copy and paste. I have attached the file I am currently working on.

View 4 Replies View Related

Debuggin The Existing Code To Copy/paste

Jul 11, 2007

I use for another template and it works fine. Only change I would like to make is the column headers starts in Row 4. Col B. Some how this is not working for me.


Application.ScreenUpdating = False

With Sheets("Data").Rows("1:1")
Set c = .Find("CONTRACT #", LookIn:=xlValues)
If Not c Is Nothing Then
FirstAddress = c.Address
Range("B3").Insert shift:=xlRight
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address FirstAddress
End If
End With
End Sub

Again...incase what I said does not make sense: I want to copy certain columns with fixed header names, e.g. "CONTRACT #" into another sheet name "Test1" and paste starting into cell B3. Another column would be "Contract Name" and so on. Also, these col header names may not be in order. In "Data" sheet, col header names starts in row 4.

View 9 Replies View Related

Copy/Paste Code Ignoring Last Row Of Data?

May 12, 2008

I am building a large macro to filter/manipulate/format/organize data pasted into a Data Dump tab.

I am a VBA novice, and I recycled some code for a portion of the macro from infomation found on this board. I just discovered that my copy/paste section is ignoring the last row of data, which is a problem ....

View 9 Replies View Related

Sort, Copy And Paste Special Code

Feb 22, 2007

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 3 Replies View Related

Code To Paste Range From Different Workbook

Jun 13, 2014

Here is the file rCell.xlsm, in order for the code to execute you need to select the green cell. When you hit the macro a copy of the workbook is placed on your desktop. The code then tries to copy a range from the copied workbook and paste it in the original macro workbook. The pasting part is crashing. In the code i marked the issue in red.

View 1 Replies View Related

Shortening VBA Code Of Copy / Paste Values With Transpose

Aug 11, 2014

I think I have a very straight forward problem, I'm copying about 400 values from one workbook to another (from vertical range to horizontal range) and I currently have about 400 lines of code in order to do this. Below I've pasted the code I'm using now but the macro takes an estimated 30 seconds to run. I figure if I can reduce the number of lines the macro will run a lot faster

RowCount = openWb.Sheets("Library Raw Shear Rates").Range("A3").CurrentRegion.Rows.Count
With openWb.Sheets("Library Raw Shear Rates").Range("A3")


View 3 Replies View Related

Code To Copy, Paste Without Replacing The Existing Data

May 21, 2009

I have two sheets - sheet1 and sheet2. Everytime i run a macro in the sheet1and manually copy the rows from sheet1 {starting (A2:AI2)} and paste as values it in the sheet2 {starting (A2:AI2)}.

Then I ll delete the available datas in the sheet1 and will run a macro for different customer.

Again I need to repeat the same action (manually copy and paste the datas to sheet2) without replacing the existing data in the sheet1.

In simple I require a macro code where it copy the available information in sheet1 and paste it as values in the sheet2 without replacing the existing one.

View 14 Replies View Related

Writing Code To Copy / Insert And Paste To Worksheet

Oct 11, 2013

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).

Sub CreatePercentageSheet()
ActiveWorkbook.Sheets("Sheet1").Copy _
ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
End Sub

View 2 Replies View Related

Copy And Paste Table From Word To Excel Code

Oct 29, 2008

i need a code to open a specific word document, copy table from word into excel with a link so when the word document is changed so is the excel doc

View 9 Replies View Related

Copy & Paste To Protected Sheet Macro Code

Apr 1, 2008

how to unprotect the sheets in order to be able copying datas to to certain cells.

The unprotection works but only when I start the macro the second time. I do not understand why.

After I did the updates I want to reprotect the sheets but that seems not to work in my case.

ActiveSheet.Unprotect Password:="my_password_here"
'unprotect the sheet

ActiveSheet.Protect DrawingObjects:=True, _
Contents:=True, Scenarios:=True, Password:="my_password_here"
' Reprotect the Sheet

View 7 Replies View Related

Copyrights 2005-15 www.BigResource.com, All rights reserved