#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Activate?

I would like to copy cells (after filling in) A4, B5, C6 and B3 into cells
F1, F2, F3 and F4 at the same time using a command button named Submit.
After copied I want original cells A4,B5,C6,B3 empty again. Please help.
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Activate?

this works but is VERY clumsy....... there's got to be a better way,
probably using an array, but i don't know how to do it.
=======================
Option Explicit

Sub move()

Dim r1 As Range
Dim r2 As Range
Dim r3 As Range
Dim r4 As Range

Set r1 = ActiveSheet.Range("a4")
Set r2 = ActiveSheet.Range("b5")
Set r3 = ActiveSheet.Range("c6")
Set r4 = ActiveSheet.Range("b3")

ActiveSheet.Range("f1").Value = r1.Value
ActiveSheet.Range("f2").Value = r2.Value
ActiveSheet.Range("f3").Value = r3.Value
ActiveSheet.Range("f4").Value = r4.Value

r1.ClearContents
r2.ClearContents
r3.ClearContents
r4.ClearContents

End Sub
==================
hope somebody else posts with something better!
:)
susan



On Jul 1, 12:46*pm, bgkgmg wrote:
I would like to copy cells (after filling in) A4, B5, C6 and B3 into cells
F1, F2, F3 and F4 at the same time using a command button named Submit. *
After copied I want original cells A4,B5,C6,B3 empty again. *Please help..
Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,316
Default Activate?

You could use this sub

Sub PickAndDrop()

Dim ws As Worksheet
Dim strSource(3) As String
Dim strTarget(3) As String
Dim i As Integer

Set ws = ThisWorkbook.ActiveSheet

strSource(0) = "A4"
strSource(1) = "B5"
strSource(2) = "C6"
strSource(3) = "B3"

strTarget(0) = "F1"
strTarget(1) = "F2"
strTarget(2) = "F3"
strTarget(3) = "F4"

For i = 0 To 3
ws.Range(strTarget(i)).Value = ws.Range(strSource(i)).Value
ws.Range(strSource(i)).Clear
Next i

Set ws = Nothing

End Sub

--
Kevin Backmann


"bgkgmg" wrote:

I would like to copy cells (after filling in) A4, B5, C6 and B3 into cells
F1, F2, F3 and F4 at the same time using a command button named Submit.
After copied I want original cells A4,B5,C6,B3 empty again. Please help.
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Activate?

All you really need is this (if the Submit button is located on the same
sheet):

Private Sub Submit_Click()
Range("F1").Value = Range("A4").Value
Range("F2").Value = Range("B5").Value
Range("F3").Value = Range("C6").Value
Range("F4").Value = Range("B3").Value
Range("A4").Value = ""
Range("B5").Value = ""
Range("C6").Value = ""
Range("B3").Value = ""
End Sub


Alan



"bgkgmg" wrote:

I would like to copy cells (after filling in) A4, B5, C6 and B3 into cells
F1, F2, F3 and F4 at the same time using a command button named Submit.
After copied I want original cells A4,B5,C6,B3 empty again. Please help.
Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Activate?

Try this...

Dim X As Long
With Worksheets("Sheet3")
For X = 0 To 3
.Range(Array("F1", "F2", "F3", "F4")(X)).Value = _
.Range(Array("A4", "B5", "C6", "B3")(X)).Value
Next
.Range("A4,B5,C6,B3").Clear
End With

Rick


"bgkgmg" wrote in message
...
I would like to copy cells (after filling in) A4, B5, C6 and B3 into cells
F1, F2, F3 and F4 at the same time using a command button named Submit.
After copied I want original cells A4,B5,C6,B3 empty again. Please help.
Thanks




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Activate?

Since you want the cells(A4,B5,C6,B3) copied after they are all have a value
you may want to add a safeguard that ensure the user has entered a value into
all 4 of the cells. I would make this modification:

Private Sub Submit_Click()

Dim i As Byte
Dim rng(3) As String

rng(0) = "A4"
rng(1) = "B5"
rng(2) = "C6"
rng(3) = "B3"

'tests cells to have a value in them
For i = 0 To 3
If IsEmpty(Range(rng(i))) Then
MsgBox "You must enter a value in Cell" & rng(i) & " to
continue.", vbExclamation
Exit Sub
End If
Next i

'copies range values
Range("F1") = Range("A4")
Range("F2") = Range("B5")
Range("F3") = Range("C6")
Range("F4") = Range("B3")

'clears range values
For i = 0 To 3
Range(rng(i)) = ""
Next i

End Sub

Hope this helps! If so please click "Yes" below.
--
Cheers,
Ryan


"bgkgmg" wrote:

I would like to copy cells (after filling in) A4, B5, C6 and B3 into cells
F1, F2, F3 and F4 at the same time using a command button named Submit.
After copied I want original cells A4,B5,C6,B3 empty again. Please help.
Thanks

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Activate?

In the 3 posts that worked they all were erased when I clicked the Submit
button again. I want the info to remain in cells F1-F4
Thanks

"bgkgmg" wrote:

I would like to copy cells (after filling in) A4, B5, C6 and B3 into cells
F1, F2, F3 and F4 at the same time using a command button named Submit.
After copied I want original cells A4,B5,C6,B3 empty again. Please help.
Thanks

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Activate?

Try this:

Private Sub Submit_Click()
If Not IsEmpty(ThisWorkbook.Sheets(Range("A4").Value) then
Range("F1").Value = Range("A4").Value
If Not IsEmpty(ThisWorkbook.Sheets(Range("B5").Value) then
Range("F2").Value = Range("B5").Value
If Not IsEmpty(ThisWorkbook.Sheets(Range("C6").Value) then
Range("F3").Value = Range("C6").Value
If Not IsEmpty(ThisWorkbook.Sheets(Range("B3").Value) then
Range("F4").Value = Range("B3").Value
Range("A4").Value = ""
Range("B5").Value = ""
Range("C6").Value = ""
Range("B3").Value = ""
End Sub


On Jul 8, 1:38*am, bgkgmg wrote:
In the 3 posts that worked they all were erased when I clicked the Submit
button again. *I want the info to remain in cells F1-F4
Thanks



"bgkgmg" wrote:
I would like to copy cells (after filling in) A4, B5, C6 and B3 into cells
F1, F2, F3 and F4 at the same time using a command button named Submit. *
After copied I want original cells A4,B5,C6,B3 empty again. *Please help.
Thanks


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
Can't activate an add-ins Ivan Setting up and Configuration of Excel 0 June 5th 08 09:33 AM
activate VBA Gary''s Student Excel Programming 0 August 17th 07 01:48 AM
activate VBA geebee Excel Programming 0 August 17th 07 01:47 AM
Windows().Activate vs Workbooks().Activate Gary''s Student Excel Programming 4 November 6th 06 02:01 PM
Workbook.Activate / Window.Activate problem Tim[_44_] Excel Programming 3 February 3rd 06 11:38 PM


All times are GMT +1. The time now is 01:59 AM.

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"