PC Review


Reply
Thread Tools Rate Thread

Copy Selected Range to new sheet

 
 
=?Utf-8?B?cmljaGllIGM=?=
Guest
Posts: n/a
 
      11th Sep 2007
I have three drop down menus that i want to select like so. 1st drop down
select building type, 2nd (C6) is dependent upon 1st and selects specific
sheet. 3rd (D6) should select range within sheet by searching for string
(veh/cyc/ped). However ranges within the sheet are different sizes and so i
need to search for a blank cell or unique char.

However range and search functions are absolute and relative.

help. very confused

Sub Addsheet()

Dim WS As Worksheet
Set WS = Sheets.Add

End Sub





Sub CopyDataToPlan()

Dim LDate As String
Dim LColumn As Integer
Dim LFound As Boolean
Dim RangeStart As String
Dim RangeEnd As String


On Error GoTo Err_Execute

'Retrieve date value to search for
LDate = Sheets("FRONT PAGE").Range("D6").Value

Sheets("C6").Select

'Start at column B
LRow = 5
LColumn = 2
LFound = False
RangeStart = A1
RangeEnd = B2

While LFound = False

'Encountered blank cell in row 2, terminate search
If Len(Cells(LRow, LColumn)) = 0 Then
MsgBox "No matching date was found."
Exit Sub

'Found match in row 2
ElseIf Cells(LRow, LColumn) = LDate Then

'Select values to copy from Selected sheet
Sheets("D6").Select
Range("RangeStart:RangeEnd").Select
Selection.Copy

'Paste onto "Plan" sheet
Sheets("Plan").Select
Cells(LRow, LColumn).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False

LFound = True
MsgBox "The data has been successfully copied."

'Continue searching
Else
LRow = LRow + 1
End If

Wend

On Error GoTo 0

Exit Sub

Err_Execute:
MsgBox "An error occurred."

End Sub


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to insert value from range on different sheet and copy sheet Diddy Microsoft Excel Programming 1 15th Aug 2009 08:40 PM
copy selected cells to new sheet. =?Utf-8?B?bWlrZQ==?= Microsoft Excel Programming 12 5th Oct 2007 10:09 AM
How do I edit a selected range then copy the range into an new sheet??? dwyborn Microsoft Excel Programming 2 16th Dec 2005 04:11 PM
define range name, use on VBA selected sheet =?Utf-8?B?Qm9iIFN3YW4=?= Microsoft Excel Programming 0 30th Jun 2005 02:08 PM
copy selected rows to new sheet Bryan Microsoft Excel Programming 2 1st Mar 2005 04:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:49 PM.