Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Need VB code for copying variable rows


  • Please log in to reply

#1
Sam Crunkleton

Sam Crunkleton

    New Member

  • Member
  • Pip
  • 2 posts
I need VB code that will complete the following process:
3 workbooks, one named master, the other two subworkbook_1 and subworkbook_2.
All workbooks have 1 worksheet. The worksheet in the Master workbook is called Master_worksheet. The worksheets in the subworkbooks are named subworksheet_1 and subworksheet_2

From the Master workbook,
open subworkbook_1
copy a finite number of columns (26)
but a variable number of rows (1 to max 5000) from subworksheet_1
activate Master_worksheet
find the first row that does not have data in it (variable from row 1 - row 60,000)
paste the copied data (values only)
close subworkbook_1
repeat above for subworkbook_2

I have a lot of the code already, but for consistency sake, please send the code to complete the process. Thank you so much! :tazz:
  • 0

Advertisements


#2
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
why dont u go and into built in vb-editor and record a macro and do itmanually nad then carefully copy code and change to ur needs

if u need more help post back

Stu design
  • 0

#3
Sam Crunkleton

Sam Crunkleton

    New Member

  • Topic Starter
  • Member
  • Pip
  • 2 posts
I have most of the code already. What I can't record is the search for the first empty row. I know the code is most likely a loop and is empty statement, I just can't get it to work. If you could give me that string of code as a sub I would be on my way. Thank you
  • 0

#4
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
Dim y As Integer
Dim x As Boolean

Sub Macro1()

Sheets("Sheet1").Select
x = True
y = 1

While x = True

Rows(y).Select

If Rows(y).Text = "" Then
    MsgBox "empty row at " & y
    x = False
    End

Else
    y = y + 1
End If

Wend

End Sub


Here's it is

Stu Design

all it takes is a little research and the help option!!!

Edited by stu_design, 31 May 2005 - 12:22 PM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP