Anthony's VBA Forum Index Anthony's VBA Forum
Where the knowledge is shared
Menu
 Anthony's VBA Forum IndexHome Page
 Anthony's VBA Forum IndexForum Index
FAQFAQ
MemberlistMemberlist
UsergroupsUsergroups
RegisterRegister
ProfileProfile
Log in to check your private messagesMessages
Log inLogin/Out

Quick Search

Advanced Search

Links
Consulting
Products

Who's Online
[ Administrator ]
[ Moderator ]


Need Help!!! Problem with my Excel Code

 
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA
View previous topic :: View next topic  
Author Message
jmccolley



Joined: 26 Dec 2007
Posts: 1

PostPosted: Wed Dec 26, 2007 5:37 pm    Post subject: Need Help!!! Problem with my Excel Code Reply with quote

I need help with some code for an excel spreadsheet that I plan to convert to HTML for our company website. I have created a workbook of our rates and discount levels with 4 worksheets (Plan A, Plan B, Plan C, Plan D) and need to be able to update Plan A so that it automatically updates sheets B, C, & D. I need it to keep the formatting and all the formulas I have in place.
With the code I have currently written, I have equipment listed by category and when I add a new piece of equipment in a category it adds the new row but then shifts the last item in the category down to the next category heading and deletets that category heading.

This is what I have:

Private Sub Worksheet_Activate()
Dim MastSht, DestSht As Worksheet
Dim last As Long
Set MastSht = Sheets("Plan A")
Set DestSht = Sheets("Plan B")
Application.ScreenUpdating = False
last = MastSht.Cells(Rows.Count, "F").End(xlUp).Row
DestSht.Range("A1:A" & last).Value = MastSht.Range("A1:A" & last).Value
DestSht.Range("B1:D" & last).Value = MastSht.Range("F1:H" & last).Value
DestSht.Range("C1:D" & last).Value = MastSht.Range("G1:H" & last).Value
DestSht.Range("D1:D" & last).Value = MastSht.Range("H1:H" & last).Value
Application.ScreenUpdating = True
End Sub
Back to top
View user's profile Send private message
mohan.ankur
Moderator
Moderator


Joined: 02 Aug 2006
Posts: 52

PostPosted: Thu Jan 03, 2008 9:39 am    Post subject: Hi Reply with quote

I think where you get the last row, may you should try...

....end(xlup).row+1

Regards
Ankur
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group