Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 31st, 2010, 02:01 PM
Registered User
 
Join Date: Jan 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple Select Copy Paste

I trying to come up with VBA code that will allow me to multiple select, insert blank rows, and then populate the new (blank) rows with text – (range (B1:N1) header row.
The code below will allow a single entry but I can’t come up with the VBA code to allow for a multiple select.
I’ve tried looping, autofilter, If statement, and other approaches but nothing is working I think the problem rests with 'ActiveCell' but not sure.

Code:
Sub Insert_Header()

	“NOTE: First row of worksheet (“B1:N1”) is header
	
	Application.ScreenUpdating = False

	‘Insert Blank row where selected in spreadsheet
		Selection.EntireRow.Insert

	‘Select blank rows & copy/paste header
		Range(“B:B”).SpecialCells(xlCellTypeBlanks).Select
		Range(“B1:N1”).Copy ActiveCell
		Application.CutCopyMode = False

	Application.ScreenUpdating = True

End Sub
 
Old February 26th, 2010, 03:17 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try to change this code
Code:
Range(“B1:N1”).Copy ActiveCell
to this
Code:
Range(“B1:N1”).Copy Selection
__________________
-vemaju





Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and Paste the value waka Excel VBA 7 October 28th, 2009 10:08 PM
Disable Copy Paste sridevi HTML Code Clinic 5 August 11th, 2007 05:09 AM
copy paste !!!!!!! dpkbahuguna Beginning VB 6 1 March 30th, 2007 10:06 AM
Copy, Paste dpkbahuguna Beginning VB 6 1 October 26th, 2006 10:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.