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 and Pasting into new Sheets

Sorry, its my 1st time working with Visual Basic i've been looking
though a lot of websites but cant find anything. i have some knowledge
with C++ and its kinda annoying not being able to write such an easy
macro.
what im trying to do is:

1. Find keyword "yyyyy" in column A
2. Find keyword "xxxx" in column A.
3. Highlight every row in between including columns A-F
4. Copy and paste in a new Sheet.
5. Start from where 2. ended and loop 1.-5. again.

thank you for reading this and hopefully help me understand how VB
works in excel. i would greatly appreciate it

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Copy and Pasting into new Sheets

Richa

Try this,
'-----------------------------------------------------
Option Explicit

Const csz_s1 As String = "yyyyyy"
Const csz_s2 As String = "xxxxxx"

Sub copyrows()
'
Dim dp As Long
Dim sp As Long
Dim b_open As Boolean
Dim wss As Worksheet
Dim wsd As Worksheet
Dim wbd As Workbook
Set wss = ActiveSheet ' point to current data sheet
Set wbd = Workbooks.Add ' new workbook
Set wsd = ActiveSheet ' point to new destination sheet

dp = 1 'destination pointer
b_open = False
For sp = 1 To 65536
With wss.Range("A" & sp)
If .Value = "" Then ' end
Set wss = Nothing
Set wbd = Nothing
Set wsd = Nothing
Exit Sub
End If
If .Value = csz_s1 Then
b_open = True
End If
If b_open Then
wss.Range("A" & sp & ":F" & sp).Copy wsd.Range("A" & dp)
dp = dp + 1
End If
If .Value = csz_s2 Then
b_open = False
End If
End With
Next sp
End Sub
'------------------------------------------------------------
--
HTHs Martin


" wrote:

Sorry, its my 1st time working with Visual Basic i've been looking
though a lot of websites but cant find anything. i have some knowledge
with C++ and its kinda annoying not being able to write such an easy
macro.
what im trying to do is:

1. Find keyword "yyyyy" in column A
2. Find keyword "xxxx" in column A.
3. Highlight every row in between including columns A-F
4. Copy and paste in a new Sheet.
5. Start from where 2. ended and loop 1.-5. again.

thank you for reading this and hopefully help me understand how VB
works in excel. i would greatly appreciate it


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Copy and Pasting into new Sheets

Hi, richa

The best way for you to learn something like this (the same as for
everyone
- myself included) is to use the Macro recorder on the Tools...Macros
menu. (Do it manual in excel, and stop recording.)

This is always the best way to start when you don't know what to do.


click Stop on the Tools..Macros menu, and use ALT-F8 to show the Macros
dialog.
You can also search "Find " in help in VB,

regards Yngve

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
Pasting Values between sheets in VBA Matt Excel Worksheet Functions 1 September 27th 06 05:41 PM
Pasting on Filtered Data Sheets without pasting onto hidden cells CCSMCA Excel Discussion (Misc queries) 1 August 28th 05 01:22 PM
in VBA Sheets("mysheet").Copy Befo=Sheets(1) how do i get a reference to the newly created copy of this sheet? Daniel Excel Worksheet Functions 1 July 6th 05 09:57 PM
Copy and pasting sheets with merged cells John Corbin[_2_] Excel Programming 2 December 19th 04 03:14 PM
HELP: Copying and pasting to Sheets... aking1987[_15_] Excel Programming 0 November 18th 04 10:28 AM


All times are GMT +1. The time now is 01:10 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"