Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ideas?

Status
Not open for further replies.

q4s72534

MIS
Aug 19, 2003
59
US
I want to pubish an excel spreadsheet in password protected excel format. Then I want to be able to delete the file and republish it password protected. Please help...

 
step 1: right now i just want to 1 copy a sheet out of a excel workbook with many sheets.

step 2: I want to past only the values and graphs(from this one sheet) into another workbook, but I'm having trouble.

I want to do these steps using vb code. i thought this task would be so easy but I'm having problems pasting the graphs and i'm getting messages saying the cell size does not match so it is unable to paste.

my script is below.

Dim wb
Dim b_value

Dim row_num As Integer

row_num = 58

wb1 = "book2.xls"
b_value = "b" & row_num

Application.Workbooks.Open (wb1)
Cells.Select
Selection.Copy
Windows("book2.xls").Activate
Range(b_value).Select
Cells.Select
Windows("book1.xls").Activate

Range("a1").Select
ActiveSheet.Paste

Select

End Sub
 
Here's code that should work
Code:
Sub test()
    Dim wb
    Dim b_value
    
    Dim row_num As Integer
    
    row_num = 58
    
    wb1 = "book2.xls"
    b_value = "b" & row_num
    
    Application.Workbooks.Open (wb1)
    ActiveSheet.UsedRange.Copy _
        Destination:=Workbooks("book2.xls").Range("a1")
End Sub
From your code, I don't know what range(b_value ) is supposed to be.

What this code does is copy the used range from book2 to A1 in book1.

Hope this helps :)

Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top