Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 31st, 2003, 08:23 AM
Brady_96Z Brady_96Z is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 2 Brady_96Z User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
excel macro copy/paste to new sheet, next row

A little background, I've got an excel spreadsheet that gets updated everyday. If there are no problems at the facility, there is nothing to paste to the other worksheet. I just need to record problems at the facility on to another worksheet. I could do it by date, but I would have big blank areas on the sheet because we only have problems a couple times a month. This spreadsheet captures a years worth of operational data.

here's what I've got so far, it may not be pretty but it works (except for the part in bold that I need to paste to the next row)

Quote:


Msg = "Comments are necessary if there was Planned or Unplanned Downtime" ' Define message.
Style = vbOKCancel + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes' button.
MyString = "Yes" ' Perform some action.
Sheets("Time").Select
Range("l21:z21").Select
Selection.Copy
Range("l22").Select
Selection.Offset(Range("k21"), 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End If

Sheets("Sheet2").Select
Range("I13:K17").Select
If Range("J37") > "0" Then
Msg = "Do you wish to submit these downtime hours?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Response = MsgBox(Msg, Style, Title)
Else: End If

If Response = vbYes Then ' User chose Yes' button.
MyString = "Yes" ' Perform some action.
Sheets("Sheet2").Select
Range("M13").Select

If Range("M13") = "" Then

Msg = "You must explain the reason for the downtime the Comments area!" ' Define message.
Style = vbOKCancel + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Response = MsgBox(Msg, Style, Title)
Else: Sheets("Sheet2").Select
Range("M13").Select
Selection.Copy
Sheets("Results").Select
Range("B40").Select
Selection.Offset(1, 0).Select


Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Sheets("Sheet2").Select
Range("L2").Select
Selection.Copy
Sheets("Results").Select
Range("A40").Select
Selection.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, SkipBlanks:= _
False, Transpose:=False
Sheets("Sheet2").Select
If Response = vbOK Then ' User chose OK' button.
MyString = "Yes" ' Perform some action.
Sheets("Sheet2").Select



I need to start @ B40 and each time there is something in M13 (and sum J37 > 0) it needs to past to B41, then the next time B42.

I hope this makes sense!
thanks!
...Brady

Reply With Quote
  #2  
Old December 31st, 2003, 10:23 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,179 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 10 h 3 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
If you're asking what I think you're asking, then this is a relatively easy problem to solve. I wrote an excel macro for a friend at work that involved something similar. What you have to do is use a static column index (pick a column that will always have a value in it if records are present), and a variable row index to loop through the records in your excel table. Use a simple comparison to determine if the field value is = " " or not, and if it is, then insert your new row using your row variable's value.
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > excel macro copy/paste to new sheet, next row


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT