• Empleos
  • Sobre nosotros
  • Empleos
    • Inicio
    • Empleos
    • Cursos y retos
  • Empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

177
Vistas
Variable en rango VBA

¿Es posible usar una variable en Range?

Tengo algunas celdas llamadas test1 , test2 , etc.

Range("test1") funciona como Range("A1"), pero Range(variable) o Range("variable") no funcionan.

Quiero establecer una variable cellName y cuando recorro test1 , test2 , las celdas llamadas test1 y test2 hacen algo.

 Dim cellName as String Dim rng As Range, cell As Range Set rng = Range("C5:C8") For each cell In rng cellName = cell.Value Worksheets("Sheet2").Range("cellName").Value = "Good" Next cell
over 3 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Probar:

 Sub test() Dim cellName As String Dim rng As Range For Each rng In Range("C5:C8") cellName = rng.Value Worksheets("Hoja1").Range(cellName).Value = "Good" Next rng Set rng = Nothing End Sub

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

over 3 years ago · Santiago Trujillo Denunciar

0

Si desea modificar celdas en C5: C8, solo necesita hacer:

 Dim cellName as String Dim rng As Range, cell As Range Set rng = Range("C5:C8") For each cell In rng cell = "Good" Next cell
over 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda