• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to scan current raw and put selected data in next sheet

HI,

I have data in sheet1 in column A, B, C, D, E, F, G, H, I, J, K, L, M as followes:


Columns as follows:

Date,

BROWSER,

P/S/D/L/

PC class

Nan Code...............

EAN Code

GTG/NGTG ............

IMAGE(Y/N)...........

Shared country.........

Char ID....................contain INDEX MATCH IF FUNCTION Chartype..................

Current Value,...........

New Value...............


I want to put button at column N for every raw and assign macro to that button so that i get following data in next sheet(columns highlited as......) from sheet1. Note i want to scan data raw by raw


Sheet2 columns like which provide output from sheet1 by each raw by pressing button


Date, (value should be copied form sheet1)

Nan code, (value should be copied form sheet1)

GTG/NGTG (value should be copied form sheet1)

IMAGE (Y/N) (value should be copied form sheet1)

Shared country.........(value should be cut form sheet1)

Char ID....................(value should be cut form sheet1)

Char type.................(value should be cut form sheet1).

Current Value,...........(value should be cut form sheet1) New Value...............(value should be cut form sheet1)


same is given as example at following link https://docs.google.com/spreadsheet/...WNNTkFMSDNoTlE


Could any one prepare macro for me?


Regards,

Pragnesh
 
It looks like the data is just getting copied over in a different order. You could probably record a macro of you copying over the columns in correct order to give you 90% of the solution.


I'm not sure what you need the macro to do when it scans each row...is there some particular criteria you are looking for? If so, you could record a macro of that by using an AutoFilter before you copy & paste.
 
I think my problem is quite simple:


Cell A2 of sheet1 should be copied to A2 in sheet2

Cell E2 of sheet1 should be copied to B2 in sheet2

Cell G2 of sheet1 should be Cut to C2 in sheet2

Cell H2 of sheet1 should be Cut to D2 in sheet2

Cell I2 of sheet1 should be Cut to E2 in sheet2

Cell J2 of sheet1 should be Cut to F2 in sheet2 (j2 contain formula in f2 which is not needed in F2 in sheet2 )

Cell K2 of sheet1 should be Cut to G2 in sheet2

Cell L2 of sheet1 should be Cut to H2 in sheet2

Cell M2 of sheet1 should be Cut to I2 in sheet2


Could any one suggest macro? Please


i have current macro as followes but it is not working well:


Sub Macro3()

'

' Macro3 Macro

' Macro recorded 9/30/2011 by patelhi02

'


'

Selection.Copy

ActiveSheet.Next.Select

Range("B2").Select

ActiveSheet.Paste

ActiveSheet.Previous.Select

Range("a2").Select

Application.CutCopyMode = False

Selection.Copy

ActiveSheet.Next.Select

Range("A2").Select

ActiveSheet.Paste

ActiveSheet.Previous.Select

Range("e2").Select

Application.CutCopyMode = False

Selection.Copy

ActiveSheet.Next.Select

Range("B2").Select

ActiveSheet.Paste

ActiveSheet.Previous.Select

Range("G2").Select

Application.CutCopyMode = False

Selection.Copy

ActiveSheet.Next.Select

Range("C2").Select

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _

:=False, Transpose:=False

ActiveSheet.Previous.Select

Range("J2:K2").Select

Application.CutCopyMode = False

Selection.Copy

ActiveSheet.Next.Select

Range("G3").Select

ActiveSheet.Paste

Rows("3:3").Select

Application.CutCopyMode = False

Selection.Insert Shift:=xlDown

ActiveSheet.Previous.Select

ActiveWorkbook.Save

End Sub


Regards,

Pragnesh
 
Like this?

[pre]
Code:
Sub TransferData()
Dim StartSheet As String
Dim EndSheet As String

'Define sheet names
StartSheet = "Sheet1"
EndSheet = "Sheet2"
Application.ScreenUpdating = False

With Worksheets(StartSheet)
Worksheets(EndSheet).Range("A2") = .Range("A2").Value
Worksheets(EndSheet).Range("B2") = .Range("E2").Value
Worksheets(EndSheet).Range("C2") = .Range("G2").Value
Worksheets(EndSheet).Range("D2") = .Range("H2").Value
Worksheets(EndSheet).Range("E2") = .Range("I2").Value
Worksheets(EndSheet).Range("F2") = .Range("J2").Value
Worksheets(EndSheet).Range("G2") = .Range("K2").Value
Worksheets(EndSheet).Range("H2") = .Range("L2").Value
Worksheets(EndSheet).Range("I2") = .Range("M2").Value
End With
Application.ScreenUpdating = True
End Sub
[/pre]
 
HI Luck M


this macro is right for raw 2, it need to scan every raw on by one.

(Note value for C to H should be cut and pasted in next sheet)


Actually i want to put Control Button in every raw of Column J,


I want to press that control button to scan current raw so that selected data transfers to next sheet.
 
Why make so many buttons??

How about you just select a cell from the row you want to copy, then press a single button/shortcut key?

[pre]
Code:
Sub TransferData()
Dim StartSheet As String
Dim EndSheet As String
Dim iRow As Integer
Dim nRow As Integer
iRow = ActiveCell.Row
'Define sheet names
StartSheet = "Sheet1"
EndSheet = "Sheet2"
Application.ScreenUpdating = False
nRow = Worksheets(EndSheet).Range("A65536").End(xlUp).Row + 1

With Worksheets(StartSheet)
Worksheets(EndSheet).Cells(nRow, "A") = .Cells(iRow, "A").Value
Worksheets(EndSheet).Cells(nRow, "B") = .Cells(iRow, "E").Value
Worksheets(EndSheet).Cells(nRow, "C") = .Cells(iRow, "G").Value
Worksheets(EndSheet).Cells(nRow, "D") = .Cells(iRow, "H").Value
Worksheets(EndSheet).Cells(nRow, "E") = .Cells(iRow, "I").Value
Worksheets(EndSheet).Cells(nRow, "F") = .Cells(iRow, "J").Value
Worksheets(EndSheet).Cells(nRow, "G") = .Cells(iRow, "K").Value
Worksheets(EndSheet).Cells(nRow, "H") = .Cells(iRow, "L").Value
Worksheets(EndSheet).Cells(nRow, "I") = .Cells(iRow, "M").Value
End With
Application.ScreenUpdating = True
End Sub
[/pre]
 
Hi Luck M


It is good to transfer all data at time.


Here data of column H to M should be removed from sheet1 after running macro rather that it remain there.
 
Within the with statement then, add line:

[pre]
Code:
.Range(.Cells(i,"H"),.Cells(i,"M")).ClearContents
[/pre]
 
[pre]
Code:
Sub TransferData()
Dim StartSheet As String
Dim EndSheet As String
Dim iRow As Integer
Dim nRow As Integer
iRow = ActiveCell.Row
'Define sheet names
StartSheet = "Sheet1"
EndSheet = "Sheet2"
Application.ScreenUpdating = False
nRow = Worksheets(EndSheet).Range("A65536").End(xlUp).Row + 1

With Worksheets(StartSheet)
Worksheets(EndSheet).Cells(nRow, "A") = .Cells(iRow, "A").Value
Worksheets(EndSheet).Cells(nRow, "B") = .Cells(iRow, "E").Value
Worksheets(EndSheet).Cells(nRow, "C") = .Cells(iRow, "G").Value
Worksheets(EndSheet).Cells(nRow, "D") = .Cells(iRow, "H").Value
Worksheets(EndSheet).Cells(nRow, "E") = .Cells(iRow, "I").Value
Worksheets(EndSheet).Cells(nRow, "F") = .Cells(iRow, "J").Value
Worksheets(EndSheet).Cells(nRow, "G") = .Cells(iRow, "K").Value
Worksheets(EndSheet).Cells(nRow, "H") = .Cells(iRow, "L").Value
Worksheets(EndSheet).Cells(nRow, "I") = .Cells(iRow, "M").Value
.Range(.Cells(i,"H"),.Cells(i,"M")).ClearContents
End With
Application.ScreenUpdating = True
End Sub
[/pre]
 
Back
Top