LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Find Empty Cell and Paste

Here's the thing - i have this code he
Basically its copying whatever value is found into the worksheet
Removed Questions.

How do i make it so that whenever i copy over the cells it pastes it
into an empty cell on the new worksheet? So it would first search for
the first blank row or cell on the "Removed Questions" - but then also
paste the information into the next blank cell.

The range to search would be ("A:A") on the "removed questions"




Dim rngLookup As String ' Value to search for
Dim rngFound As Range ' Cell rngLookup is found in
Dim firstAddress As String 'Cell address of the first value found
Dim wksDisplayResults As Worksheet ' Output sheet
Dim wksMaster As Worksheet 'Master Questions sheet

Dim ri As Long ' Row Index used to know which row results should
paste into
Dim bContinue As Boolean ' Used to stop find loop

Set wksMaster = Worksheets("Master Questions")
Set wksDisplayResults = Worksheets("Removed Questions")

ri = 2 'Row to begin pasting results

rngLookup = "D" ' Value to search for

'Before beginning loop, copy the header to result sheet
wksMaster.Range("a1").EntireRow.Copy wksDisplayResults.Range("a1")

' Find Lookup Value
With Worksheets("Master Questions").Range("e2:e65000")
Set rngFound = .Find(rngLookup, _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=True)
'Return message if value not found
If rngFound Is Nothing Then
MsgBox ("The search item " & rngLookup & " was not
found")
Else
firstAddress = rngFound.Address
bContinue = True

'Continue looping until bcontinue is false
Do While bContinue
'Cut or copy row into result sheet, then increment
the row index
rngFound.EntireRow.Copy wksDisplayResults.Rows(ri)
ri = ri + 1
'Find the next cell containing lookup value
Set rngFound = .FindNext(rngFound)
'If range found is not nothing, then bContinue will
remain true
bContinue = Not rngFound Is Nothing
'Then check to see if rngfound's address is equal
to firstaddress
If bContinue = True Then bContinue =
rngFound.Address < firstAddress
Loop
End If
End With


End If

 
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
Paste to next empty cell in named range of cells Sully Excel Discussion (Misc queries) 3 March 4th 10 05:23 PM
Find Empty Cell in Row Steve C Excel Programming 2 November 20th 05 01:55 AM
I need to find the first empty row in a sheet to paste data to rgbivens Excel Programming 2 April 7th 05 07:29 PM
Paste Selction In First Empty Cell derekc[_14_] Excel Programming 2 July 1st 04 06:35 PM
Find Empty Column and paste cell values Mike Excel Programming 6 December 28th 03 08:31 PM


All times are GMT +1. The time now is 01:45 AM.

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

About Us

"It's about Microsoft Excel"