Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 74
Default Can I simplify a VB code??????

Thanks Luke I shall try that. I'll let you know!

"Luke M" wrote:

'Rather than doing a copy & paste, you can tell VB directly
'that one cell equals another


Private Sub Worksheet_Calculate()
Application.ScreenUpdating = False

With Sheets("Sheet2")
.Range("J188") = .Range("J187").Value
.Range("J193") = .Range("J192").Value
.Range("K188") = .Range("K187").Value
.Range("L188") = .Range("L187").Value
End With

End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"hoyos" wrote:

Is there an easier way of writing this code?

Private Sub Worksheet_Calculate()
Application.ScreenUpdating = False

Sheets("Sheet2").Range("j187").Copy
Sheets("Sheet2").Range("j188").PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Sheets("Sheet2").Range("j192").Copy
Sheets("Sheet2").Range("j193").PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Sheets("Sheet2").Range("k187").Copy
Sheets("Sheet2").Range("k188").PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Sheets("Sheet2").Range("l187").Copy
Sheets("Sheet2").Range("l188").PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Application.CutCopyMode = False

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 74
Default Can I simplify a VB code??????

Thanks Luke it works.
The problem I am getting now, when changing a value in one of the textboxes,
takes along time to run through the calculations.
Any ideas?

"hoyos" wrote:

Thanks Luke I shall try that. I'll let you know!

"Luke M" wrote:

'Rather than doing a copy & paste, you can tell VB directly
'that one cell equals another


Private Sub Worksheet_Calculate()
Application.ScreenUpdating = False

With Sheets("Sheet2")
.Range("J188") = .Range("J187").Value
.Range("J193") = .Range("J192").Value
.Range("K188") = .Range("K187").Value
.Range("L188") = .Range("L187").Value
End With

End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"hoyos" wrote:

Is there an easier way of writing this code?

Private Sub Worksheet_Calculate()
Application.ScreenUpdating = False

Sheets("Sheet2").Range("j187").Copy
Sheets("Sheet2").Range("j188").PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Sheets("Sheet2").Range("j192").Copy
Sheets("Sheet2").Range("j193").PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Sheets("Sheet2").Range("k187").Copy
Sheets("Sheet2").Range("k188").PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Sheets("Sheet2").Range("l187").Copy
Sheets("Sheet2").Range("l188").PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Application.CutCopyMode = False

End Sub

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
I need to simplify this... j5b9721 Excel Worksheet Functions 5 July 23rd 09 09:03 AM
Simplify code Inkel Excel Worksheet Functions 3 March 27th 09 05:52 PM
Is there anyway to simplify this formula? rancher fred Excel Worksheet Functions 1 January 6th 07 09:29 PM
Need to simplify code alexwren Excel Discussion (Misc queries) 7 August 15th 06 08:07 PM
simplify code matt Excel Discussion (Misc queries) 3 September 28th 05 11:53 PM


All times are GMT +1. The time now is 09:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"