
Private Sub cmdimp1_10_Click()
Call cmdimp1_Click(ur:=Uriga1, col1:=12, col2:=2, col3:=13, col4:=3)
Call cmdimp1_Click(ur2:=Uriga3, col1:=14, col2:=5, col3:=15, col4:=6)
Call cmdimp1_Click(ur3:=Uriga4, col1:=16, col2:=8, col3:=17, col4:=9)
Call cmdimp1_Click(ur4:=Uriga5, col1:=18, col2:=11, col3:=19, col4:=12)
Call cmdimp1_Click(ur5:=Uriga6, col1:=20, col2:=14, col3:=21, col4:=15)
Call cmdimp1_Click(ur6:=Uriga7, col1:=22, col2:=17, col3:=23, col4:=18)
Call cmdimp1_Click(ur7:=Uriga8, col1:=24, col2:=20, col3:=25, col4:=21)
Call cmdimp1_Click(ur8:=Uriga9, col1:=26, col2:=23, col3:=27, col4:=24)
Call cmdimp1_Click(ur9:=Uriga10, col1:=28, col2:=26, col3:=29, col4:=27)
Call cmdimp1_Click(ur10:=Uriga11, col1:=30, col2:=29, col3:=31, col4:=30)
End Sub
Private Sub cmdimp1_Click()
Dim wb1 As Workbook, wb2 As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
Dim Area As Range, RR As Range
Dim Uriga1 As Long, Uriga2 As Long, R As Long, X As Long
Dim ur As Long, ur2 As Long, ur3 As Long, ur4 As Long, ur5 As Long, ur6 As Long, ur7 As Long, ur8 As Long, ur9 As Long, ur10 As Long
Dim col1 As Long, col2 As Long, col3 As Long, col4 As Long
Dim ID As String, percorso As String, nomeFile As String
Set wb1 = ThisWorkbook
Set ws1 = wb1.Worksheets("Db_buyer")
Application.ScreenUpdating = False
Application.EnableEvents = False
'On Error Resume Next
Uriga2 = ws1.Range("E" & ws1.Rows.Count).End(xlUp).Row
percorso = "\CLUSTERFSSharePiano MarketingDb_promo_buyerDb_miglior_promo.xlsm"
Set wb2 = Application.Workbooks.Open(percorso)
Set ws2 = wb2.Worksheets("Promo_buyer")
Uriga1 = ws2.Range("A" & ws2.Rows.Count).End(xlUp).Row
Set Area = ws2.Range("A1:A" & Uriga1)
Uriga3 = ws2.Range("D" & ws2.Rows.Count).End(xlUp).Row
Set Area = ws2.Range("D1:D" & Uriga3)
Uriga4 = ws2.Range("G" & ws2.Rows.Count).End(xlUp).Row
Set Area = ws2.Range("G1:G" & Uriga4)
Uriga5 = ws2.Range("J" & ws2.Rows.Count).End(xlUp).Row
Set Area = ws2.Range("J1:J" & Uriga5)
Uriga6 = ws2.Range("M" & ws2.Rows.Count).End(xlUp).Row
Set Area = ws2.Range("M1:M" & Uriga6)
Uriga7 = ws2.Range("P" & ws2.Rows.Count).End(xlUp).Row
Set Area = ws2.Range("P1:P" & Uriga7)
Uriga8 = ws2.Range("S" & ws2.Rows.Count).End(xlUp).Row
Set Area = ws2.Range("S1:S" & Uriga8)
Uriga9 = ws2.Range("V" & ws2.Rows.Count).End(xlUp).Row
Set Area = ws2.Range("V1:V" & Uriga9)
Uriga10 = ws2.Range("Y" & ws2.Rows.Count).End(xlUp).Row
Set Area = ws2.Range("Y1:Y" & Uriga10)
Uriga11 = ws2.Range("AB" & ws2.Rows.Count).End(xlUp).Row
Set Area = ws2.Range("AB1:AB" & Uriga11)
For X = 3 To Uriga2
ID = ws1.Cells(X, 5).Value
Set RR = Area.Find(ID, LookIn:=xlValues, Lookat:=xlWhole)
If Not RR Is Nothing Then
ws1.Cells(X, col1) = ws2.Cells(RR.Row, col2)
ws1.Cells(X, col3) = ws2.Cells(RR.Row, col4)
Set RR = Nothing
End If
Next X
Application.ScreenUpdating = True
Application.EnableEvents = True
wb2.Close SaveChanges:=True
Application.DisplayAlerts = True
'MsgBox "Aggiornamento eseguito con successo"
Set ws1 = Nothing
Set wb1 = Nothing
Set ws2 = Nothing
Set wb2 = Nothing
Set Area = Nothing
End Sub
|
Private Sub cmdimp1_Click()
Dim wb1 As Workbook, wb2 As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
Dim Area As Range, RR As Range, Y As Long, X As Long
'Dim Urow As Long, Ur2 As Long, Urow2 As Long, Urow3 As Long, Urow4 As Long, Urow5 As Long, Urow6 As Long, Urow7 As Long, Urow8 As Long, Urow9 As Long, Urow10 As Long, R As Long, X As Long
Dim Ur1 As Long
Dim col1 As Long, col2 As Long, col3 As Long ', col4 As Long
Dim ID As String, percorso As String, nomeFile As String
Set wb1 = ThisWorkbook
Set ws1 = wb1.Worksheets("Db_buyer")
Application.ScreenUpdating = False
Application.EnableEvents = False
'On Error Resume Next
Ur1 = ws1.Range("E" & ws1.Rows.Count).End(xlUp).Row
percorso = "C:Documents and SettingsLello-SatDesktopDb_miglior_promo.xlsm" '"\CLUSTERFSSharePiano MarketingDb_promo_buyerDb_miglior_promo.xlsm"
Set wb2 = Application.Workbooks.Open(percorso)
Set ws2 = wb2.Worksheets("Promo_buyer")
'non setto l'area e non calcolo quanto sono lunghe le colonne, metto 1000000
For X = 3 To Ur1
col1 = 1
col2 = 2
col3 = 3
ID = ws1.Cells(X, 5).Value
For Y = 1 To 10
Set RR = ws2.Range(ws2.Cells(1000000, col1), ws2.Cells(Y, col1)).Find(ID, LookIn:=xlValues)
If Not RR Is Nothing Then
' non so in quale cella copiare 'ws1.Cells(X, ???) = ws2.Cells(RR.Row, col1 + 1)
' non so in quale cella copiare 'ws1.Cells(X, ???) = ws2.Cells(RR.Row, col1 + 2)
MsgBox "Trovato"
'Set RR = Nothing
End If
col1 = col1 + 3
col2 = col2 + 3
col3 = col3 + 3
Next Y
Next X
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = False
wb2.Close SaveChanges:=True
Application.DisplayAlerts = True
MsgBox "Aggiornamento eseguito con successo"
Set ws1 = Nothing
Set wb1 = Nothing
Set ws2 = Nothing
Set wb2 = Nothing
Set RR = Nothing
End Sub
|
Private Sub cmdimp1_10_Click()
Option Explicit
Private Sub cmdtrovapromo_Click()
Dim wb1 As Workbook, wb2 As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
Dim Area As Range, RR As Range
Dim R As Long, X As Long
Dim urigafrom As Long, urigato As Long
Dim col1 As Long
Dim ID As String, percorso As String, nomeFile As String
Set wb1 = ThisWorkbook
Set ws1 = wb1.Worksheets("Db_buyer")
Application.ScreenUpdating = False
Application.EnableEvents = False
'On Error Resume Next
urigato = ws1.Range("E" & ws1.Rows.Count).End(xlUp).Row ' seleziono l'intero intervallo da verificare
percorso = "\CLUSTERFSSharePiano MarketingDb_promo_buyerDb_miglior_promo.xlsm" ' apro il percorso dove cercare i dati
Set wb2 = Application.Workbooks.Open(percorso)
Set ws2 = wb2.Worksheets("Promo_buyer")
'ora dovrei trovare gli intervalli e le aree da dove prendere i dati
'che sono "A","D","G","J","M","P","S","V","Y","AB" (((Per un totale di 10 aree)))
urigafrom = ws2.Range("A" & ws2.Rows.Count).End(xlUp).Row ' intervallo "A"
Set Area = ws2.Range("A1:A" & urigafrom) ' area "A"
For X = 3 To urigato ' parto dalla riga 3 + ultima riga del range "E"
col1 = 1 ' creo la variabile colonna 1 e quando dovrò spostarmi di colonna metto il + n (Es col1 +3)
ID = ws1.Cells(X, 5).Value ' devo trovare i riferimenti della colonna 5 nelle 10 aree
'é qui mi casca la testa
''''''''''''''''''''''''
Set RR = Area.Find(ID, LookIn:=xlValues, Lookat:=xlWhole)
If Not RR Is Nothing Then
ws1.Cells(X, col1 + 11) = ws2.Cells(RR.Row, col1 + 1) 'esempio con area a
ws1.Cells(X, col1 + 12) = ws2.Cells(RR.Row, col1 + 2) 'esempio con aria a
'''ps qui mi fermo perchè non capisco ...purtroppo .....le troppe aree mi hanno incasinato
Set RR = Nothing
End If
Next X
Application.ScreenUpdating = True
Application.EnableEvents = True
wb2.Close SaveChanges:=True
Application.DisplayAlerts = True
'MsgBox "Aggiornamento eseguito con successo"
Set ws1 = Nothing
Set wb1 = Nothing
Set ws2 = Nothing
Set wb2 = Nothing
Set Area = Nothing
End Sub
|
Public Function LettCol(ByVal n As Long) As String 'By Scossa LettCol = Replace(Cells(1, n).Address(False, False), "1", "") End Function |
Private Sub cmdimp1_Click()
Dim wb1 As Workbook, wb2 As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
Dim Area As Range, RR As Range
Dim Uriga1 As Long, Uriga2 As Long, R As Long, X As Long
Dim ID As String, percorso As String, nomeFile As String
Set wb1 = ThisWorkbook
Set ws1 = wb1.Worksheets("Db_buyer")
Application.ScreenUpdating = False
Application.EnableEvents = False
'On Error Resume Next
Uriga2 = ws1.Range("E" & ws1.Rows.Count).End(xlUp).Row
percorso = "\CLUSTERFSSharePiano MarketingDb_promo_buyerDb_miglior_promo.xlsm"
Set wb2 = Application.Workbooks.Open(percorso)
Set ws2 = wb2.Worksheets("Promo_buyer")
Uriga1 = ws2.Range("A" & ws2.Rows.Count).End(xlUp).Row
Set Area = ws2.Range("A1:A" & Uriga1)
For X = 3 To Uriga2
ID = ws1.Cells(X, 5).Value
Set RR = Area.Find(ID, LookIn:=xlValues, Lookat:=xlWhole)
If Not RR Is Nothing Then
ws1.Cells(X, 12) = ws2.Cells(RR.Row, 2)
ws1.Cells(X, 13) = ws2.Cells(RR.Row, 3)
Set RR = Nothing
End If
Next X
Application.ScreenUpdating = True
Application.EnableEvents = True
wb2.Close SaveChanges:=True
Application.DisplayAlerts = True
'MsgBox "Aggiornamento eseguito con successo"
Set ws1 = Nothing
Set wb1 = Nothing
Set ws2 = Nothing
Set wb2 = Nothing
Set Area = Nothing
End Sub |
Option Explicit
Sub ricerca()
Dim wb1 As Workbook: Set wb1 = ThisWorkbook
Dim sh1 As Worksheet: Set sh1 = wb1.Worksheets("Db_buyer")
Dim Area As Range, RR As Range
Dim Ur1 As Long, Ur2 As Long, Y As Long, X As Long, Col1 As Long, Col2 As Long, Col3 As Long
Dim ID As String, percorso As String, nomeFile As String
Application.ScreenUpdating = False
Application.EnableEvents = False
Ur1 = sh1.Range("E" & sh1.Rows.Count).End(xlUp).Row
percorso = "C:Documents and SettingsLello-SatDesktopDb_miglior_promo.xlsm" '"\CLUSTERFSSharePiano MarketingDb_promo_buyerDb_miglior_promo.xlsm"
Dim wb2 As Workbook: Set wb2 = Application.Workbooks.Open(percorso) ' da cambiare casomai
Dim sh2 As Worksheet: Set sh2 = wb2.Worksheets("Promo_buyer") ' da cambiare casomai
For X = 3 To Ur1
Col1 = 1
ID = sh1.Cells(X, 5).Value
For Y = 1 To 10
Ur2 = sh2.Range(LettCol(Col1) & sh2.Rows.Count).End(xlUp).Row
Set RR = sh2.Range(sh2.Cells(1, Col1), sh2.Cells(Ur2, Col1)).Find(ID, LookIn:=xlValues) ' non c'è bisogno di fare SET AREA
If RR Is Nothing Then
Else
Select Case LettCol(Col1)
Case "A"
MsgBox "Colonna A = Trovato, se desideri la prima cella destra sh1.(cells(x,???) = sh2.(cells(RR,col1 +1)"
MsgBox "Colonna A = Trovato, se desideri la seconda cella destra sh1.(cells(x,???) = sh2.(cells(RR,col1 +2)"
Col1 = Col1 + 3 'dato che non hai risposto e ho trovato ID, aggiungo 3 ed esco dal ciclo
Exit For
Case "D"
MsgBox "Cosa fare??????"
Exit For 'dato che non hai risposto e ho trovato ID, aggiungo 3 ed esco dal ciclo
Case "G"
MsgBox "Cosa fare??????"
Exit For 'dato che non hai risposto e ho trovato ID, aggiungo 3 ed esco dal ciclo
' ne mancano altri 7
End Select
End If
Next Y
Next X
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = False
wb2.Close SaveChanges:=True
Application.DisplayAlerts = True
MsgBox "Aggiornamento eseguito con successo"
Set sh1 = Nothing
Set wb1 = Nothing
Set sh2 = Nothing
Set wb2 = Nothing
Set RR = Nothing
End Sub |
Option Explicit
Sub ricerca()
Dim wb1 As Workbook: Set wb1 = ThisWorkbook
Dim sh1 As Worksheet: Set sh1 = wb1.Worksheets("Db_buyer")
Dim Area As Range, RR As Range
Dim Ur1 As Long, Ur2 As Long, Y As Long, X As Long, Col1 As Long, Col2 As Long, Col3 As Long
Dim ID As String, percorso As String, nomeFile As String
Dim Col As String
Application.ScreenUpdating = False
Application.EnableEvents = False
Ur1 = sh1.Range("E" & sh1.Rows.Count).End(xlUp).Row
percorso = "\CLUSTERFSSharePiano MarketingDb_promo_buyerDb_miglior_promo.xlsm"
Dim wb2 As Workbook: Set wb2 = Application.Workbooks.Open(percorso) ' da cambiare casomai
Dim sh2 As Worksheet: Set sh2 = wb2.Worksheets("Promo_buyer") ' da cambiare casomai
For X = 3 To Ur1
Col1 = 1
ID = sh1.Cells(X, 5).Value
For Y = 1 To 10
Col = LettCol(Col1)
Ur2 = sh2.Range(Col & sh2.Rows.Count).End(xlUp).Row
Set RR = sh2.Range(sh2.Cells(1, Col1), sh2.Cells(Ur2, Col1)).Find(ID, LookIn:=xlValues) ' non c'è bisogno di fare SET AREA
If RR Is Nothing Then
Else
Select Case Col
Case "A"
sh1.Cells(X, 12) = sh2.Cells(RR, Col1 + 1)
sh1.Cells(X, 13) = sh2.Cells(RR, Col1 + 2)
Col1 = Col1 + 3
Case "D"
sh1.Cells(X, 14) = sh2.Cells(RR, Col1 + 4)
sh1.Cells(X, 15) = sh2.Cells(RR, Col1 + 5)
Col1 = Col1 + 3
Case "G"
sh1.Cells(X, 16) = sh2.Cells(RR, Col1 + 7)
sh1.Cells(X, 17) = sh2.Cells(RR, Col1 + 8)
Col1 = Col1 + 3
Case "J"
sh1.Cells(X, 18) = sh2.Cells(RR, Col1 + 10)
sh1.Cells(X, 19) = sh2.Cells(RR, Col1 + 11)
Col1 = Col1 + 3
Case "M"
sh1.Cells(X, 20) = sh2.Cells(RR, Col1 + 13)
sh1.Cells(X, 21) = sh2.Cells(RR, Col1 + 14)
Col1 = Col1 + 3
Case "P"
sh1.Cells(X, 22) = sh2.Cells(RR, Col1 + 16)
sh1.Cells(X, 23) = sh2.Cells(RR, Col1 + 17)
Col1 = Col1 + 3
Case "S"
sh1.Cells(X, 24) = sh2.Cells(RR, Col1 + 19)
sh1.Cells(X, 25) = sh2.Cells(RR, Col1 + 20)
Col1 = Col1 + 21
Case "V"
sh1.Cells(X, 26) = sh2.Cells(RR, Col1 + 22)
sh1.Cells(X, 27) = sh2.Cells(RR, Col1 + 23)
Col1 = Col1 + 3
Case "Y"
sh1.Cells(X, 28) = sh2.Cells(RR, Col1 + 25)
sh1.Cells(X, 29) = sh2.Cells(RR, Col1 + 26)
Col1 = Col1 + 3
Case "AB"
sh1.Cells(X, 30) = sh2.Cells(RR, Col1 + 28)
sh1.Cells(X, 31) = sh2.Cells(RR, Col1 + 29)
Col1 = Col1 + 3
End Select
End If
Next Y
Next X
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = False
wb2.Close SaveChanges:=True
Application.DisplayAlerts = True
MsgBox "Aggiornamento eseguito con successo"
Set sh1 = Nothing
Set wb1 = Nothing
Set sh2 = Nothing
Set wb2 = Nothing
Set RR = Nothing
End Sub
Public Function LettCol(ByVal n As Long) As String 'By Scossa
LettCol = Replace(Cells(1, n).Address(False, False), "1", "")
End Function
|
Option Explicit
Sub ricerca()
Dim wb1 As Workbook: Set wb1 = ThisWorkbook
Dim sh1 As Worksheet: Set sh1 = wb1.Worksheets("Db_buyer")
Dim Area As Range, RR As Range
Dim Ur1 As Long, Ur2 As Long, Y As Long, X As Long, Col1 As Long, Col2 As Long, Col3 As Long
Dim ID As String, percorso As String, nomeFile As String
Dim Col As String
Application.ScreenUpdating = False
Application.EnableEvents = False
Ur1 = sh1.Range("E" & sh1.Rows.Count).End(xlUp).Row
percorso = "\CLUSTERFSSharePiano MarketingDb_promo_buyerDb_miglior_promo.xlsm"
Dim wb2 As Workbook: Set wb2 = Application.Workbooks.Open(percorso) ' da cambiare casomai
Dim sh2 As Worksheet: Set sh2 = wb2.Worksheets("Promo_buyer") ' da cambiare casomai
For X = 3 To Ur1
Col1 = 1
ID = sh1.Cells(X, 5).Value
For Y = 1 To 10
Col = LettCol(Col1)
Ur2 = sh2.Range(Col & sh2.Rows.Count).End(xlUp).Row
Set RR = sh2.Range(sh2.Cells(1, Col1), sh2.Cells(Ur2, Col1)).Find(ID, LookIn:=xlValues) ' non c'è bisogno di fare SET AREA
If RR Is Nothing Then
Else
Select Case Col
Case "A"
sh1.Cells(X, 12) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 13) = sh2.Cells(RR.Row, Col1 + 2)
Col1 = Col1 + 3
Case "D"
sh1.Cells(X, 14) = sh2.Cells(RR.Row, Col1 + 4)
sh1.Cells(X, 15) = sh2.Cells(RR.Row, Col1 + 5)
Col1 = Col1 + 3
Case "G"
sh1.Cells(X, 16) = sh2.Cells(RR.Row, Col1 + 7)
sh1.Cells(X, 17) = sh2.Cells(RR.Row, Col1 + 8)
Col1 = Col1 + 3
Case "J"
sh1.Cells(X, 18) = sh2.Cells(RR.Row, Col1 + 10)
sh1.Cells(X, 19) = sh2.Cells(RR.Row, Col1 + 11)
Col1 = Col1 + 3
Case "M"
sh1.Cells(X, 20) = sh2.Cells(RR.Row, Col1 + 13)
sh1.Cells(X, 21) = sh2.Cells(RR.Row, Col1 + 14)
Col1 = Col1 + 3
Case "P"
sh1.Cells(X, 22) = sh2.Cells(RR.Row, Col1 + 16)
sh1.Cells(X, 23) = sh2.Cells(RR.Row, Col1 + 17)
Col1 = Col1 + 3
Case "S"
sh1.Cells(X, 24) = sh2.Cells(RR.Row, Col1 + 19)
sh1.Cells(X, 25) = sh2.Cells(RR.Row, Col1 + 20)
Col1 = Col1 + 21
Case "V"
sh1.Cells(X, 26) = sh2.Cells(RR.Row, Col1 + 22)
sh1.Cells(X, 27) = sh2.Cells(RR.Row, Col1 + 23)
Col1 = Col1 + 3
Case "Y"
sh1.Cells(X, 28) = sh2.Cells(RR.Row, Col1 + 25)
sh1.Cells(X, 29) = sh2.Cells(RR.Row, Col1 + 26)
Col1 = Col1 + 3
Case "AB"
sh1.Cells(X, 30) = sh2.Cells(RR.Row, Col1 + 28)
sh1.Cells(X, 31) = sh2.Cells(RR.Row, Col1 + 29)
Col1 = Col1 + 3
End Select
End If
Next Y
Next X
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = False
wb2.Close SaveChanges:=True
Application.DisplayAlerts = True
MsgBox "Aggiornamento eseguito con successo"
Set sh1 = Nothing
Set wb1 = Nothing
Set sh2 = Nothing
Set wb2 = Nothing
Set RR = Nothing
End Sub
|
'..........
If RR Is Nothing Then
Col1 = Col1 + 3
Else
Select Case Col
Case "A"
sh1.Cells(X, 12) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 13) = sh2.Cells(RR.Row, Col1 + 2)
Exit For
Case "D"
sh1.Cells(X, 14) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 15) = sh2.Cells(RR.Row, Col1 + 2)
Exit For
Case "G"
'............... |
Option Explicit
Sub ricerca()
Dim wb1 As Workbook: Set wb1 = ThisWorkbook
Dim sh1 As Worksheet: Set sh1 = wb1.Worksheets("Db_buyer")
Dim Area As Range, RR As Range
Dim Ur1 As Long, Ur2 As Long, Y As Long, X As Long, Col1 As Long, Col2 As Long, Col3 As Long
Dim ID As String, percorso As String, nomeFile As String
Dim Col As String
Application.ScreenUpdating = False
Application.EnableEvents = False
Ur1 = sh1.Range("E" & sh1.Rows.Count).End(xlUp).Row
sh1.Range("L3:AE" & Ur1).ClearContents
percorso = "C:Users
icola.spanuDesktopDb_miglior_promo_loc.xlsm"
Dim wb2 As Workbook: Set wb2 = Application.Workbooks.Open(percorso) ' da cambiare casomai
Dim sh2 As Worksheet: Set sh2 = wb2.Worksheets("Promo_buyer") ' da cambiare casomai
For X = 3 To Ur1
Col1 = 1
ID = sh1.Cells(X, 5).Value
For Y = 1 To 10
Col = LettCol(Col1)
Ur2 = sh2.Range(Col & sh2.Rows.Count).End(xlUp).Row
Set RR = sh2.Range(sh2.Cells(1, Col1), sh2.Cells(Ur2, Col1)).Find(ID, LookIn:=xlValues) ' non c'è bisogno di fare SET AREA
If RR Is Nothing Then
Col1 = Col1 + 3
Else
Select Case Col
Case "A"
sh1.Cells(X, 12) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 13) = sh2.Cells(RR.Row, Col1 + 2)
Col1 = Col1 + 3
Case "D"
sh1.Cells(X, 14) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 15) = sh2.Cells(RR.Row, Col1 + 2)
Col1 = Col1 + 3
Case "G"
sh1.Cells(X, 16) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 17) = sh2.Cells(RR.Row, Col1 + 2)
Col1 = Col1 + 3
Case "J"
sh1.Cells(X, 18) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 19) = sh2.Cells(RR.Row, Col1 + 2)
Col1 = Col1 + 3
Case "M"
sh1.Cells(X, 20) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 21) = sh2.Cells(RR.Row, Col1 + 2)
Col1 = Col1 + 3
Case "P"
sh1.Cells(X, 22) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 23) = sh2.Cells(RR.Row, Col1 + 2)
Col1 = Col1 + 3
Case "S"
sh1.Cells(X, 24) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 25) = sh2.Cells(RR.Row, Col1 + 2)
Col1 = Col1 + 3
Case "V"
sh1.Cells(X, 26) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 27) = sh2.Cells(RR.Row, Col1 + 2)
Col1 = Col1 + 3
Case "Y"
sh1.Cells(X, 28) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 29) = sh2.Cells(RR.Row, Col1 + 2)
Col1 = Col1 + 3
Case "AB"
sh1.Cells(X, 30) = sh2.Cells(RR.Row, Col1 + 1)
sh1.Cells(X, 31) = sh2.Cells(RR.Row, Col1 + 2)
Col1 = Col1 + 3
End Select
End If
Next Y
Next X
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = False
wb2.Close SaveChanges:=True
Application.DisplayAlerts = True
MsgBox "Aggiornamento eseguito con successo"
Set sh1 = Nothing
Set wb1 = Nothing
Set sh2 = Nothing
Set wb2 = Nothing
Set RR = Nothing
End Sub
Public Function LettCol(ByVal n As Long) As String 'By Scossa da inserire in un modulo
LettCol = Replace(Cells(1, n).Address(False, False), "1", "")
End Function
|
