Here's a macro that should do what you've asked for. You have some work to
do to complete the code: you need to change
Const destSheetName = "X" ' change as needed
to the actual name of the destination sheet instead of "X", so if your
destination sheet's name is Sheet3 it would change to = "Sheet3"
Then farther down in the code you have to provide the destination cell
addresses for the elements of array cellMap(). I put in the 1st 3 based on
your posting, but you need to provide the ones for cellMap(4) through
cellMap(25).
To put the code into the workbook, open it and press [Alt]+[F11] to open the
VB Editor. In it, choose Insert --> Module and then copy the code below and
paste it into the module and edit it as required. Then close the VB Editor.
To run it later, choose the cell in column BX below the first cell you want
to copy and use Tools --> Macro --> Macros and choose it from the list and
click [Run]. Or you can put a button or shape on the source sheet and assign
the macro to it.
Sub CopyFromColumnBX()
'this should be the name of your 'X' sheet
'the sheet to copy from BX into
Const destSheetName = "X" ' change as needed
Dim destSheet As Worksheet
'this array will hold the addresses of the
'cells on sheet 'X' that the data is to
'be copied into.
Dim cellMap(1 To 25) As String
Dim LC As Integer ' loop counter
If ActiveCell.Column <> Range("BX1").Column Then
Exit Sub ' not in column BX
End If
'if we get here, we have work to do
'fill the array with the destination
'addresses.
cellMap(1) = "A9"
cellMap(2) = "AC11"
cellMap(3) = "C19"
'you need to fill in the rest of the
'destination cell addresses
cellMap(4) = ""
cellMap(5) = ""
cellMap(6) = ""
cellMap(7) = ""
cellMap(8) = ""
cellMap(9) = ""
cellMap(10) = ""
cellMap(11) = ""
cellMap(12) = ""
cellMap(13) = ""
cellMap(14) = ""
cellMap(15) = ""
cellMap(16) = ""
cellMap(17) = ""
cellMap(18) = ""
cellMap(19) = ""
cellMap(20) = ""
cellMap(21) = ""
cellMap(22) = ""
cellMap(23) = ""
cellMap(24) = ""
cellMap(25) = ""
'this is where the work actually gets done
Set destSheet = _
ThisWorkbook.Worksheets(destSheetName)
For LC = LBound(cellMap) To UBound(cellMap)
'safety valve if no address in cellMap() entry
If cellMap(LC) <> "" Then
destSheet.Range(cellMap(LC)) = _
ActiveCell.Offset(LC * -1, 0)
End If
Next
Set destSheet = Nothing ' housekeeping
End Sub
ash3154 said:
Hello,
I am hoping someone can assist me. My spreadsheets consists of 70 columns
and 2000 rows.
If my active cell is bx400, I would like to copy value of bx399 into
spreadsheet "X"'s cell a9. Then take the value of bx398 and copy that into
spreadsheet "X" 's cell ac11, bx397 would be copied to sheet X cell c19 and
so on for the previous 25 rows. (This should only be done when I click on
the macro button)