KEMBAR78
Codigo Formato | PDF
0% found this document useful (0 votes)
12 views3 pages

Codigo Formato

The document contains two VBA subroutines for Excel: 'Correct_formato' formats specific cells in sheets 'Ordenes' and 'TRA' to text and copies values from those cells. The second subroutine, 'MARCAR_errores', searches for the term 'SRC_NM' in specified sheets and checks for errors in related values, marking cells with errors in red. Both routines automate data handling and error checking within Excel spreadsheets.

Uploaded by

r2senosain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Codigo Formato

The document contains two VBA subroutines for Excel: 'Correct_formato' formats specific cells in sheets 'Ordenes' and 'TRA' to text and copies values from those cells. The second subroutine, 'MARCAR_errores', searches for the term 'SRC_NM' in specified sheets and checks for errors in related values, marking cells with errors in red. Both routines automate data handling and error checking within Excel spreadsheets.

Uploaded by

r2senosain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Sub Correct_formato()

Dim W_VALOR As String


w_hoja = "Ordenes"
'8: ORDEN
' 1: HOJA ORDEN
For I = 2 To 580
' i = 134
DIRECCION = Sheets(w_hoja).Cells(I, 1).Address
Range(DIRECCION).Select
Selection.NumberFormat = "@"
W_VALOR = Sheets(w_hoja).Cells(I, 1)
ActiveCell.FormulaR1C1 = W_VALOR
Range(DIRECCION).Select
' ActiveCell.Value = Sheets(W_HOJA).Cells(i, 8)
Next

w_hoja = "TRA"
'8: ORDEN
' 1: HOJA ORDEN
For I = 2 To 1200
' i = 134
DIRECCION = Sheets(w_hoja).Cells(I, 8).Address
Range(DIRECCION).Select
Selection.NumberFormat = "@"
W_VALOR = Sheets(w_hoja).Cells(I, 8)
ActiveCell.FormulaR1C1 = W_VALOR
Range(DIRECCION).Select
' ActiveCell.Value = Sheets(W_HOJA).Cells(i, 8)
Next

End Sub

Sub MARCAR_errores()

Dim W_VALOR As String

w_hoja = "PRD"
w_hoja = "REF"
w_hoja = "TRA"
'*****************
'buscar SRC_NM
'*****************
Sheets(w_hoja).Select
Cells.Find(What:="SRC_NM", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
DIRECCION_SRC = ActiveCell.Address
COLUMNA_SRC = Range(DIRECCION_SRC).Column

I = 2
While Sheets(w_hoja).Cells(I, COLUMNA_SRC) <> ""

W_VALOR = Sheets(w_hoja).Cells(I, COLUMNA_SRC)


Sheets("AUX").Select
Range("H2").Select
ActiveCell.FormulaR1C1 = W_VALOR

' Sheets("AUX").Cells(2, 8) = Sheets(w_hoja).Cells(I, COLUMNA_SRC)

'declaramos dinamicamente w_comp


W_COMP_1 = Sheets("AUX").Cells(2, 9).Value
W_COMP_2 = Sheets("AUX").Cells(2, 10).Value
W_COMP_3 = Sheets("AUX").Cells(2, 11).Value

If IsError(W_COMP_1) And IsError(W_COMP_2) And IsError(W_COMP_3) Then

Sheets(w_hoja).Cells(I, 15) = "error"

DIRECCION = Sheets(w_hoja).Cells(I, 8).Address


Sheets(w_hoja).Select
Sheets(w_hoja).Range(DIRECCION).Select
With Selection.Interior
.Color = 255
End With

DIRECCION = Sheets(w_hoja).Cells(I, 15).Address


Sheets(w_hoja).Select
Sheets(w_hoja).Range(DIRECCION).Select
With Selection.Interior
.Color = 255
End With

Else

End If

I = I + 1
Wend
End Sub

You might also like