PDA

View Full Version : Data editing/moving/arrange.



Thypec
10-24-2012, 01:02 AM
Hi everyone,

I am new in VBA and I am trying to learn it. I woudl like to do some data editing/moving/arrange.

I would like to do this activity:
Sheet1 - output from DB
Sheet2 - data what I woudl like to have

Compare from Sheet2 "A2" and cell "N1" in sheet1 if true then copy from sheet1 cell "BG2" in sheet2 in column "N2", then continue compare "A2" and "O1"...loop to "S1" and copy cell "BG2" under relevant column in sheet2. If is done go to next culomn A "A3" and so on.

I have no idea how to start, therefore thanky you for any help.

Bob Phillips
10-24-2012, 02:43 AM
Public Sub ProcessData()

With ActiveSheet

.Columns("AV:BI").Delete
.Columns("Q:AO").Delete
.Columns("H:N").Delete
.Columns("E").Delete
.Columns("C").Delete
.Columns("C").Cut
.Columns("A").Insert

.Range("N1:S1").Value = Array("QSP", "QRP", "QPR", "SQR", "QPL", "GAP")
.Range("A1").Copy
.Range("N1:S1").PasteSpecial Paste:=xlPasteFormats
End With
End Sub

Thypec
10-24-2012, 04:01 AM
XLD thank you, but is not exactly what i mean, maybe was my explanation wrong then I try again.

I expect following steps from macro:
1) Check value (text) from cell "A2" in sheet2 ("3JEZ11BQ001_3.01.02") if this value (text) is in column "A" (sheet1).

Note: Some values (text) can be more time in column "A" in sheet1 just with different code (for example QRP, QPR, SQR, OPL..etc. in column "BH" in sheet1) ; that means value can occur multiple times and i need all finded values (not just first one)

2) Check if value (code - "QSP" ) specified in cell "N1" (sheet2) is in column "BH" (sheet1) and if yes then copy value from related cell in column "BG" (sheet1) into the column "N2" (sheet2)

3) Same steps as is described in step two i need also for other s codes, (QRP, QPR, SQR, OPL..etc.)

General note:
A) Value (text) highlted by blue color in sheet2 should be finded in sheet1.

B)Value (text) highlted by green color in sheet1 should be copied to sheet2.