Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy Selected Range to new sheet

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy a selected Range to a Workbook Dooley[_2_] Excel Programming 3 June 23rd 07 09:16 PM
How do I edit a selected range then copy the range into an new sheet??? dwyborn Excel Programming 2 December 16th 05 04:11 PM
How to copy selected listbox item to sheet michdan Excel Programming 1 July 14th 05 12:49 PM
Nameing a range while still selected from copy Jim at Eagle Excel Programming 5 April 10th 05 07:21 PM
copy selected rows to new sheet Bryan[_13_] Excel Programming 2 March 1st 05 04:17 AM


All times are GMT +1. The time now is 02:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"