Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 349
Default Copy From A Range To A Range

Hello All,
I am trying to figure out how to copy values from a range to another range.

I have a checkbox setup in each row from 16-45. If the checkbox is ticked it
will copy the range "B(row number)" to "K(same row number)" to a new sheet
and insert it under the last entry within rows 16-45.
There are no formula's or anything to be copied, just the cell contents.
Any advice welcomed

Regards
Peter


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy From A Range To A Range

Hi Peter

If you use Linkedcell for each checkbox you can use AutoFilter to
filter on TRUE.
This way you can copy it to a new sheet

Maybe you like this
http://www.rondebruin.nl/copy5.htm




--
Regards Ron de Bruin
http://www.rondebruin.nl



"Peter" wrote in message ...
Hello All,
I am trying to figure out how to copy values from a range to another range.

I have a checkbox setup in each row from 16-45. If the checkbox is ticked it
will copy the range "B(row number)" to "K(same row number)" to a new sheet
and insert it under the last entry within rows 16-45.
There are no formula's or anything to be copied, just the cell contents.
Any advice welcomed

Regards
Peter




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Copy From A Range To A Range

Did you use a checkbox from the Control Toolbox toolbar or from the Forms
toolbar?

I think for things like this, the Forms toolbar version of the checkbox is lots
easier to work with.

You can assign the same macro to each of those checkboxes.

I used column B of the Sheet2 to determine the next available row.

Option Explicit
Sub testme()

Dim myCBX As CheckBox
Dim myRow As Long
Dim DestCell As Range
Dim RngToCopy As Range

With ActiveSheet
Set myCBX = .CheckBoxes(Application.Caller)

If myCBX.Value = xlOff Then
Exit Sub
End If

myRow = myCBX.TopLeftCell.Row

Set RngToCopy = .Range(.Cells(myRow, "B"), .Cells(myRow, "K"))

End With

With Worksheets("sheet2")
Set DestCell = .Cells(.Rows.Count, "B").End(xlUp).Offset(1, 0)
End With

DestCell.Resize(RngToCopy.Rows.Count, RngToCopy.Columns.Count).Value _
= RngToCopy.Value

myCBX.Value = xlOff

End Sub


Peter wrote:

Hello All,
I am trying to figure out how to copy values from a range to another range.

I have a checkbox setup in each row from 16-45. If the checkbox is ticked it
will copy the range "B(row number)" to "K(same row number)" to a new sheet
and insert it under the last entry within rows 16-45.
There are no formula's or anything to be copied, just the cell contents.
Any advice welcomed

Regards
Peter


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 349
Default Copy From A Range To A Range

Thanks Dave and Ron =)

I have now used the checkboxes from the forms toolbar, and it works..I still
have one slight problem though.
How do I set it to not go past "B46", but instead open another sheet if it
needs to?

Regards
Peter

"Dave Peterson" wrote:

Did you use a checkbox from the Control Toolbox toolbar or from the Forms
toolbar?

I think for things like this, the Forms toolbar version of the checkbox is lots
easier to work with.

You can assign the same macro to each of those checkboxes.

I used column B of the Sheet2 to determine the next available row.

Option Explicit
Sub testme()

Dim myCBX As CheckBox
Dim myRow As Long
Dim DestCell As Range
Dim RngToCopy As Range

With ActiveSheet
Set myCBX = .CheckBoxes(Application.Caller)

If myCBX.Value = xlOff Then
Exit Sub
End If

myRow = myCBX.TopLeftCell.Row

Set RngToCopy = .Range(.Cells(myRow, "B"), .Cells(myRow, "K"))

End With

With Worksheets("sheet2")
Set DestCell = .Cells(.Rows.Count, "B").End(xlUp).Offset(1, 0)
End With

DestCell.Resize(RngToCopy.Rows.Count, RngToCopy.Columns.Count).Value _
= RngToCopy.Value

myCBX.Value = xlOff

End Sub


Peter wrote:

Hello All,
I am trying to figure out how to copy values from a range to another range.

I have a checkbox setup in each row from 16-45. If the checkbox is ticked it
will copy the range "B(row number)" to "K(same row number)" to a new sheet
and insert it under the last entry within rows 16-45.
There are no formula's or anything to be copied, just the cell contents.
Any advice welcomed

Regards
Peter


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Copy From A Range To A Range

How about:

Option Explicit
Dim OtherWks As Worksheet
Sub testme()

Dim myCBX As CheckBox
Dim myRow As Long
Dim DestCell As Range
Dim RngToCopy As Range
Dim maxRow As Long
Dim CurSelection As Range

Application.ScreenUpdating = False

If OtherWks Is Nothing Then
Set OtherWks = Worksheets("sheet2")
End If
maxRow = 46

With ActiveSheet
Set myCBX = .CheckBoxes(Application.Caller)

If myCBX.Value = xlOff Then
Exit Sub
End If

myRow = myCBX.TopLeftCell.Row

Set RngToCopy = .Range(.Cells(myRow, "B"), .Cells(myRow, "K"))

End With

With OtherWks
Set DestCell = .Cells(.Rows.Count, "B").End(xlUp).Offset(1, 0)
End With

If DestCell.Row maxRow Then
Set CurSelection = Selection
Set OtherWks = Worksheets.Add
Set DestCell = OtherWks.Range("b1")
Application.Goto CurSelection
End If

DestCell.Resize(RngToCopy.Rows.Count, RngToCopy.Columns.Count).Value _
= RngToCopy.Value

myCBX.Value = xlOff
Beep 'just a noise

Application.ScreenUpdating = True

End Sub

Peter wrote:

Thanks Dave and Ron =)

I have now used the checkboxes from the forms toolbar, and it works..I still
have one slight problem though.
How do I set it to not go past "B46", but instead open another sheet if it
needs to?

Regards
Peter

"Dave Peterson" wrote:

Did you use a checkbox from the Control Toolbox toolbar or from the Forms
toolbar?

I think for things like this, the Forms toolbar version of the checkbox is lots
easier to work with.

You can assign the same macro to each of those checkboxes.

I used column B of the Sheet2 to determine the next available row.

Option Explicit
Sub testme()

Dim myCBX As CheckBox
Dim myRow As Long
Dim DestCell As Range
Dim RngToCopy As Range

With ActiveSheet
Set myCBX = .CheckBoxes(Application.Caller)

If myCBX.Value = xlOff Then
Exit Sub
End If

myRow = myCBX.TopLeftCell.Row

Set RngToCopy = .Range(.Cells(myRow, "B"), .Cells(myRow, "K"))

End With

With Worksheets("sheet2")
Set DestCell = .Cells(.Rows.Count, "B").End(xlUp).Offset(1, 0)
End With

DestCell.Resize(RngToCopy.Rows.Count, RngToCopy.Columns.Count).Value _
= RngToCopy.Value

myCBX.Value = xlOff

End Sub


Peter wrote:

Hello All,
I am trying to figure out how to copy values from a range to another range.

I have a checkbox setup in each row from 16-45. If the checkbox is ticked it
will copy the range "B(row number)" to "K(same row number)" to a new sheet
and insert it under the last entry within rows 16-45.
There are no formula's or anything to be copied, just the cell contents.
Any advice welcomed

Regards
Peter


--

Dave Peterson


--

Dave Peterson
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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
RANGE EXCEL copy cell that meets criteria in a range confused Excel Worksheet Functions 3 March 27th 08 01:41 PM
copy range and paste into every 3rd cell of new range thomsonpa New Users to Excel 4 December 3rd 07 01:47 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM
Range COPY function - how to copy VALUES and not formulas James Cooke Excel Programming 1 August 21st 03 07:04 PM


All times are GMT +1. The time now is 03:08 AM.

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

About Us

"It's about Microsoft Excel"