Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Bucles for

publicado

Buenas, estoy intentando hacer un programa VBA el qual me coja un valor ya establecido aleario, por ejemplo en "A1" y este colocarlo dentro de una formula: valor(C1)=A1*B1 con tambien B1 conocido,para que me de el valor en C1.

El problema que tengo es que dentro de la formula quiero que B1 me varie hasta B100... valor(C2)=A1*B2.. etc y una vez tengo los 100 valores que me salte a la siguiente celda A2 y repita la operacion: valor(C101)=A2*B1. Hasta A1000.... tendre C100000 celdas.

Con macros no se como utilizar la funcion For dentro de ellas.

Y hay algun problema si uso C(1000*10000)=C(10000000) me lo va aceptar Excel?

Mi programa lo tengo hecho: y me sale error pero no se porque en la formula:

Sub Programa()

Dim ro As Single

Dim Pn As Single

Dim i As Integer

Dim j As Integer

Dim k As Integer

Dim Valory As Double

Dim ValorEpsilon As Double

Dim ValorRn As Double

ValorRn = 0

ro = 0.15

Pn = 0.01

Call Macro1

Call Macro2

(macros que me dan los numeros de la columna A i B, aleatorios)

For i = 1 To 10

Cells(i, 1).Select

Valory = ActiveCell

For j = 1 To 10

Cells(j, 2).Select

ValorEpsilon = ActiveCell

For k = 1 To 100

ValorRn = Valory ^ (1 / 2) + ((1 - ro) ^ (1 / 2)) * ValorEpsilon

ActiveCell(k, 5).Value = ValorRn

Next k

Next j

Next i

End Sub

MUchas gracias

Featured Replies

publicado
  • Autor

No puedo subir el archivo excel... aca les dejo el codigo entero.

Sub Macro1()

'

' Macro1 Macro

'creacion de numeros aleatorios

'

Application.Run "ATPVBAEN.XLAM!Random", ActiveSheet.Range("$A$1"), 1, _

10000, 2, , 0, 1

Range("B1").Select

End Sub

Sub Macro2()

'

' Macro2 Macro

'creacion de numeros aleatorios

'

Application.Run "ATPVBAEN.XLAM!Random", ActiveSheet.Range("$B$1"), 1, 1000 _

, 2, , 0, 1

Range("E7").Select

End Sub

Sub Programa()

Dim ro As Single

Dim Pn As Single

Dim i As Integer

Dim j As Integer

Dim k As Integer

Dim Valory As Double

Dim ValorEpsilon As Double

Dim ValorRn As Double

'constantes

ro = 0.15

Pn = 0.01

Call Macro1

Call Macro2

'bucle para leer los valores de la primera columna, seran: Valory

For i = 1 To 10

Cells(i, 1).Select

Valory = ActiveCell

'bucle para cada valory leera todos los valores de valorepsilon

For j = 1 To 100

Cells(j, 2).Select

ValorEpsilon = ActiveCell

'bucle que calcula el resultado de la operacion. si tenemos: 10 valory i 100 valorEpsilon= 1000 valores de ValorRn

For k = 1 To 1000

ActiveCell(k, 4).Value = ValorRn

ValorRn = Valory ^ (1 / 2) + ((1 - ro) ^ (1 / 2)) * ValorEpsilon

' error en la fórmula???

Next k

Next j

Next i

'cerrar bucles

End Sub

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.